I've installed Magento into a subfolder /var/www/html/magento2 When I access it I need to type http://xxx.xxx.xxx.xxx/magento2

How is it possible to navigate to site without using the subfolder ? Is this related to .htaccess file, I have not edited nor moved files around yet.


3 Answers 3


Edit your .htaccess file in your root folder(/var/www/html/) with below code.

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

In your case replace subfolder with magento2. Its working for me, check once.

  • The only item in html is a folder called magento2. So I copied .htaccess to html (leaving the original as is) and deleted all content and added the above code. But now I receive a 500 error when I browse to either ip or ip/magento2. Could this be permission related? Dec 1, 2016 at 10:00
  • Don' copy the .htaccess file from magento2 subfolder. If you didn't find the file in /var/www/html, then create new one and use my code. Dec 1, 2016 at 10:06
  • created new file nano .htaccess and added your code, changed two instances of 'subfolder' but same error. Dec 1, 2016 at 10:15
  • Can you check the permissions of file and remove the two lines, Mod Rewrite and Options +FollowSymLinks, if you are not using the godaddy hosting. Dec 1, 2016 at 10:24
  • I removed the godaddy hosting line and its now worked :) When I browse to ip it now changes the url automatically to ip/magento2 and page renders. Is there a way to remove the magento2 from the url ? In mageto admin I found the following under 'Base URL' Dec 1, 2016 at 10:28

if you are using xampp then run your xampp control panel click the button saying config select apache( httpd.conf ) otherwise edit httpd.conf find document root replace

DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">

Those 2 lines

| C:/xampp/htdocs == current location for root |

|change C:/xampp/htdocs with any location you want|

save it and restart xampp


I wrote a post about this link -> post

As everything goes through the /pub/ folder, you need to create /pub/subfolder and then change the relative path on the index.php file:

From: require realpath(DIR) . ‘/../app/bootstrap.php’;

To: require realpath(DIR) . ‘/../../app/bootstrap.php’;

It worked to me with Nginx and Magento 2.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.