Domanda

I have a magento2.4 store running on server. I installed it on localhost but it give 404 error. enter image description here

It has a strange .htaccess file contents.

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

If i change the .htaccess file content to a standard M2 .htaccess than it gives directory content. enter image description here

Can you suggest some solution to this problem?

È stato utile?

Soluzione

This problem you are facing is due to the new rules of M2.4.2 which will now serve all requests from the <magento_root>/pub folder. This is kind of incompatible with what you are trying to do - launching Magento from a folder directly in browser without a dedicated virtual host.

You have 2 options:

  1. Create a dedicated virtual host and set the DocumentRoot to point to the <magento_root>/pub folder - for this approach check my answer in this thread The requested URL /pub/ was not found on this server. - Magento .htaccess problem
  2. Try to make Magento accept that you are not having a dedicated virtual host and adapt the Apache instructions - and for this approach I suggest you read the answers given by me and @iphigenie in the thread frontend and admin not working magento 2.4.2 upgrade

Good Luck!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top