Magento 2.2.5 redirect from sub to root

618 Views Asked by At

I am new to Magento. Successfully installed/implemented Magento 2.2.5. However, I installed Magento as subfolder in root. And my cart shows as mydomainname.example/magento. I want to change it so public does not see 'magento' in my URL. I found several posts regarding it.e.g. How To Direct Magento installation path in subfolder to main domain name. My challenge is that Magento 2.2.5 index.php file does not have any code line 45 that I can edit.

2

There are 2 best solutions below

3
On

First thing the referenced solution is a Magento 1, it's a very different framework from Magento 2!

In your case I think you need to edit the .htaccess in the parent folder like in this post

# Mod Rewrite
Options +FollowSymLinks  #Include this line if you are using Godaddy hosting
RewriteEngine On
RewriteCond %{REQUEST_URI} !(.*)magento
RewriteRule ^(.*)$ magento/$1 [L]

at last, I recommend https://magento.stackexchange.com/ for the magento related questions as it's dedicated to Magento

3
On

You can try to move all folders from Magento to the root.

But if you need subfolders anyway you can use one of this solutions:

1) Open apache or nginx settings and specify the Magento folder as the "root directory" of your website.

2) You can also create file at the root, name it index.php and the content will be <?php require __DIR__ . '/magento/index.php'; ?>