All content of .htaccess is gone after upgraded to Magento 2.4.0 to 2.4.4

Only these 7 lines are still here now. How to fix it every time we upgrade Magento? Can Mr. Craig provide the original content of .htaccess of Magento 2.4.0 for general please?

螢幕快照 2022-05-02 下午11.52.40

How to install Magento 2.4 and build a web server

Most of contents moved to file “.htaccess.sample” after Magento upgrating, and php_value memory_limit 756MB need to be replaced again by the maximum memory of our server.

But how can we keep our setting of .htaccess everytime we upgrade the Magento version?

In 2.4.x, Magento moved the .htaccess file (that contains the configurations) from <magento root>/ to <Magento root>/pub/.

<magento root>/.htaccess

The contents of <magento root>/.htaccess should just not be the below. No reason to modify this file anymore:

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

<magento root>/pub/.htaccess

Therefore, any changes such as memory_limit should be made only in <magento root>/pub/.htaccess.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.