cancel
Showing results for 
Search instead for 
Did you mean: 

.htaccess file for Magento 2.4

.htaccess file for Magento 2.4

Hello,

I have installed Magento 2.4 on Apache 2 sever running on Ubuntu 20.x

When I try to load the magento root directory on browser, I get

 

 

Not Found
The requested URL was not found on this server.

 

 

I have the .htaccess (default file created by install) like this

 

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

 

 

Can someone help me understand what this is trying to do?

 

My understanding is, this is looking for index.php file (which is not present in the root installation directory - and thus the error).

 

I have a feeling that the error has to do something with the line

 

RewriteRule .* /pub/$0 [L]

 

 

Thanks in advance!

1 REPLY 1

Re: .htaccess file for Magento 2.4

The default, root .htacess is the same as yours.

 

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

I've noticed as of version 2.4.2 there is another .htaccess file in /pub which is the .htaccess file that was originally root. Please check /pub/.htaccess too. The corresponding index.php is stored in /pub too.

If it's a fresh install of Magento then generally it's a server side issue. Check for missing php packages, check error log.