Magento 404 error page not found: Page not found and how to fix it in Magento 2

One of the popular faults is the 404 error page not found. It happens quite often and your Magento page can happen too if you don’t pay attention to it. As the result, customers find it difficult to reach your page and your store. And as the result, the volume of visitors can decrease considerably, and your revenue may be affected badly. Therefore, you need to take care of your website to avoid this situation. If not visitors won’t have a seamless experience when visiting the website and it’s the reason they don’t want to come back. Then this post is definitely for you if you meet a situation and don’t know how to address it with Magento 404 error. Let’s jump in to know more information.

Why does a 404 error page not found happen?

404 error page not found

404 Error means that the page you were looking for was not found. Usually, it is for two reasons:

  • You inserted the wrong URL
  • The page has been removed.

Also, it often happens, that a store includes into its functional any extension for URL structure changing (for example, Layered Navigation with friendly URLs). Such a kind of extension update or removal can lead to a 404 error.

In Magento, when a store was migrated to Magento 2 from another e-commerce platform (Prestashop, Shopify, Drupal, WooCommerce, etc) or from Magento 1, the search systems contain several pages with old URLs and give a try to re-index, obtain a Magento 404 error page not found in response.

Related topic:

>> 404 page: How to create and customize it effectively in Magento 2?

How to get the list of pages with 404 errors?

Magento 404 error page not found

We considered possible reasons. But before start looking for the solution, we must find the bearings of the issue. We must obtain the full list of your store’s 404 pages. It is possible in the following ways:

Get 404 pages from Google Search Console

Just open Google Search Console and visit the page Crawl > Crawl Errors > Not Found

Get 404 pages from Google Analytics

In Google Analytics, it is required to use the parameter “404” and filter the list of all your store pages. As it is represented on the screenshot

How to resolve Magento 404 error page?

Well, you have a full list of Magento 404 error page not found and now you have to redirect a user to new, relevant pages. There are several options available to solve this task:

Flush and Clear Magento Cache by Command line or remove folders manually.

php bin/magento cache:clean
rm -rf var/cache/*
rm -rf var/generation/*

Alternatively, you can use Cpanel to clear the cache and create a folder inside a var folder.

Enable Rewrite mode

If the 404 errors persist after flushing the Magento cache, try enabling the rewrite mode with the following command:

sudo a2enmod rewrite

Configure the apache after you’ve run the following command.

If you’re using Ubuntu, you’ll need to edit the file /etc/apache2/apache2.conf by running the command:

sudo vi /etc/apache2/apache2.conf

After that, you need to change the following:

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

Into:

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Finally, use the following command to restart Apache:

sudo service apache2 restart

Or

sudo /etc/init.d/apache2 restart

Or

sudo systemctl restart apache2

htaccess file in the root

Magento 404 error page

Upload the default. htaccess file to the Magento installation’s root

Check the admin URL from the env.php file.

Go to app/etc/env.php and open that file
Look for the admin URL, code should look like this
From @app/etc/env.php, you may see/change the admin URL.

return array (
'backend' =>
array (
'frontName' => 'admin_q76xvk',
),

The admin URL is the one that is highlighted. Make sure you’re typing the admin URL correctly.

For the local environment sometimes URL issues like

During Setup, you can replace the URL i.e., http://localhost/ with http://127.0.0.1/

Delete Var/ Cache Folder

Finally, if the following four solutions don’t fix all of your store’s 404 issues, it’s time to delete the var/cache folder.
After you’ve deleted the folder, go to database SELECT * FROM core_config_data WHERE path = ‘web/seo/use_rewrites’ and change it to 0.

Finally, type the following URL into your browser:

magento_base_url/index.php/your_admin_url

Conclusion

Well, today, we learned how to fix the Magento 404 error page not found for admin. We hope you can avoid this situation through the information we share with you. This problem won’t be your concern anymore when you can address it quickly to avoid interrupting the performance of your website. Share it with your Magento colleagues and friends if you enjoy what we are sharing. If you are still feeling about how to solve it quickly and correctly, don’t worry, we are here with Magento Website Development service to help you overcome this problem easily. Therefore, don’t hesitate to contact us now to receive the best consultation.