Magento – Magento 2.4.2 Window10 localhost Xampp 404 not found

localhostmagento2.4.2not foundwindows10xampp

I just installed Magento 2, it shown the success page result however the homepage and admin is not found.

enter image description here

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

Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/7.4.16 Server at localhost Port 80

enter image description here
enter image description here

Magento 2.4.2
Window10 64
XAMPP 3.2.4
Elasticsearch-7.11.2
Composer 2.0.11

Best Answer

Step 1: -

We need to set document root to pub, to do this go to file C:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/magento24/pub"
    ServerName yourname.magento.com
</VirtualHost>

paste this code at the bottom of the file.

yourname.magento.com - this is domain name which you set as per your wish. So now you need to access magento frontend and admin with base url "yourname.magento.com".

Step 2:-

Now lets edit C:\Windows\System32\drivers\etc\hosts file and add the below line at the bottom of the file.

 127.0.0.1  yourname.magento.com

Step 3: - Update the base URL:

Go to our magento database and run below command

  UPDATE core_config_data SET value='http://yourname.magento.com/' WHERE path='web/unsecure/base_url';

Step 4:- Update the app/etc/env.php file

The following node needs to be appended to the env.php file.

'directories' => [
    'document_root_is_pub' => true
 ]

Step 5 : - Switch to developer mode.

php bin/magento deploy:mode:set developer
php bin/magento cache:flush

Hurray !!! All done .... Lets check your

homepage http://yourname.magento.com/ and

admin page http://yourname.magento.com/admin

Related Topic