[Solve] The requested URL was not found on this server after installing Magento 2

After installing Magento 2, you may face the problem “The requested URL was not found on this server“. You cannot access both backend and frontend of Magento 2 even it’s just a fresh installation.

The error looks like this

requested URL not found magento 2

What is the cause of this error?

The error occurs because of .htaccess file on your Magento 2 installation folder. Htaccess file is missing or wrong setting make Magento 2.

If you’re using Nginx, the rewrite part of Nginx conf file may be missing or not working.

Temporarily solution

You can gain access to website by putting “index.php” in the url like this example: yourwebsite.com/index.php or for admin access: /magento2/index.php/admin

Permanent fix

You need a proper .htacess file to make URL rewrite works.

You can download the file here

After downloading the file, rename it from .htaccess.sample to .htaccess and put into Magento root folder

In case the error is still there after putting new .htaccess file, you will have to check if rewrite module is enabled on your web server

For apache:

Change apache virtual host file (by default located in /etc/httpd/conf/httpd.conf) from:

To

This will enable mod_rewrite for apache

Now restart apache and the site should work normally

For nginx

Add these lines:

After you’re done, restart Nginx to see if the error is fixed

Note: Nginx does not support .htaccess file, so you don’t need .htaccess file if you are using Nginx as your web server

Now your site should work properly

site working

Explanation

The following lines missing in .htaccess file may cause.

RewriteRule .* index.php [L] rewrite all the URLs to url/index.php so that you can access all url without putting index.php

If you still face the error after trying all the solution above, drop your comment here and I will try my best to fix it for you.

The following two tabs change content below.

Hung Tran

I'm a computer geek who has experience working with Magento and Magento 2. I help my client build website in Magento and test different types of hosting and module for Magento.

1 thought on “[Solve] The requested URL was not found on this server after installing Magento 2”

  1. Hi,

    Struggling big time with this – site was working all great untill ssl was installed on the server and now a bunch of pages are giving a 404 error but mainly the admin area.
    Its running on ubuntu 18, magento 2.3
    Admin area gives a 404 no matter what link i try sitename/index.php/admin redirects to sitename/admin/index

    I tried everything .htaccess file, mod rewrite, virtual directory, manually in the databse but just no success.

    the actual site is working – just the admin area is not.

Leave a Comment