cancel
Showing results for 
Search instead for 
Did you mean: 

what is the correct apache + htaccess settings

what is the correct apache + htaccess settings

Hi all, following the official guide to install 2.4 I am not able to successfully start the shop. It ends up like this:Screenshot 2022-06-16 at 16.25.25.png

 

So, I created the project in subfolder "shop" from my document root /var/www/html. Accordingly I put this in my 000-default.conf of the apache configuation:

<Directory "/var/www/html/shop">
    AllowOverride All
</Directory>

I started the magento setup:install routine with localhost/shop as my base-url. That went through ending up with an .htaccess file in /var/www/html/shop:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /pub/$0 [L]
DirectoryIndex index.php

in pub, there also is an .htaccess but it looks very different. 

Calling http://localhost/shop does NOT work here, it ends up with a 404. When I change my htaccess like this

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /shop/pub/$0 [L]
DirectoryIndex index.php

(see line 6 where I added /shop) I can call the storefront but without any pages or links working (see screenshot above). 

Also, the admin link is not working.

I already deployed static content, cleaned the cache and rebuild but this did not change anything.

I guess manipulating the htaccess like I did only works for parts of it. Nowhere in the documentation it is said to modify this line however. When I leave everything as it is after installation it does not work. When I understood the rewrite rules correctly all request under localhost/shop should go to localhost/shop/pub but this does not happen.

When I manually enter localhost/shop/pub I can see the "Home Page" with "CMS homepage content goes here." as content. Seems to be correct. 

 

 

Any hints here?

 

 

1 REPLY 1

Re: what is the correct apache + htaccess settings

I am facing with same issue.

Did you find solution for this to run magento 2 in subfolder.