Magento 2.4.2 .htaccess changes...

I have just noticed, In Magento 2.4.2 release, the Magento root folder .htaccess file changed completely compared to the 2.4.1 release. I found this commit without much explanation, due to this change if the URI does not starts with pub, setup, update, dev, it will rewrite to the magento-root/pub/*. Previously magento recommends to set pub/ as doc root for the security reason. I hope this is the reason they modified .htaccess.

In the below examples, we set magento-root/ as doc root in the apache (not magento-root/pub/)

Example 1:

http://magento.default.m242/static/version1613058997/frontend/Magento/luma/en_US/mage/calendar.css (This will work because this URI does not start with pub so rewrite to pub/)


http://magento.default.m242/pub/static/version1613058997/frontend/Magento/luma/en_US/mage/calendar.css (This will also work because this URI already starts with pub so it will work as usual)


Example 2:

If we create a test.html file inside magento-root/, it will show 404 when we access http://magento.default.m242/test.html, because it does not start with pub so it will rewrite to pub/, in pub/ we don't have test.html so it will show 404 not found page.


If we create a test.html file inside magento-root/pub, it will show the page correctly when we access http://magento.default.m242/test.html, because it does not start with pub so it will rewrite to pub/, in pub/ we have test.html so it will show page correctly.

17 views0 comments

Recent Posts

See All

Check TTFB from Ubuntu terminal

We can print the TTFB multiple times by using the below command in the ubuntu terminal. for i in {0..3}; do echo -n "$i :: "; curl --resolve 'www.yoursite.com:443:your-ip' --output /dev/null -w "Respo

Magento 2 CMS block with the same ID already exists

I have seen the below error when I open cms block grid something went wrong with processing the default view and we have restored the filter to its original state. I found the below log in the excepti

How to generate bearer token - Magento 2 REST API

We can generate the admin bearer token using the below command. Please run the below command in the terminal to generate a token. curl -XPOST -H 'Content-Type: application/json' http://www.domain.com/

Follow Me

  • LinkedIn
  • Twitter
  • Facebook
  • YouTube
  • Instagram

©2020 by Bilal Usean. Proudly created with Wix.com