23

Am struggling with a strange error in magento 2.

Have a setup where i have removed some stores, so now only single store.

Am trying to set the home page in admin (CMS Home Page)

No matter what I do, it says 404 on home page, all other pages work.

Have looked in database, setting for is: web/default/cms_home_page is there and set ok and for scope_id = 0.

not sure which pages it is looking for, is there a way to debug that?

any other suggestions for how to fix this?

3
  • did you solve this problem? If so, could you tell me how? I am facing the same problem and it driving me nuts. I have tried so many things but as you said: "No matter what I do, it says 404 on home page, all other pages work." Best regards
    – Ben
    Commented Dec 13, 2018 at 12:46
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review Commented Dec 13, 2018 at 13:07
  • Somehow after deleting the empty entires on my multi store config 2.3.3. i now have a Chrome error saying ERR_TOO_MANY_REDIRECTS I cleared cookies cache but nothing helps? In the past i have deleted entries without getting this message. Ai...Help
    – Robbert
    Commented Jan 16, 2021 at 9:26

4 Answers 4

45

It can happen if one of the products is miss-configured/bad-saved/bad-imported especially url_rewrite table is missing request_path value.

What i did to fix it... Open MySQL console & run this query and see which product(s) has an empty request_path

SELECT * FROM `url_rewrite` WHERE request_path='';

Remove those entities & Clear the cache. Now you can enjoy your homepage ;)

2
  • Another case is Full page cache can’t distinguish GET request from HEAD request. If you do not have cached data or it is invalidated and web crawler send HEAD type request to your site, magento return 404 page and cache it. More here - nwdthemes.com/2019/06/28/magento-2-homepage-404-error Commented Jul 1, 2019 at 11:24
  • There should be one things in addition. SELECT * FROM url_rewrite WHERE request_path='/'; remove those Commented Jun 29, 2021 at 7:35
16

In my case,

The categories entity had an empty request_path.

Go to the database and with the help of this command find the categories or products entities that have an empty request_path

SELECT * FROM `url_rewrite` WHERE request_path='';

Delete all those entries and use the cache clean and flush command:

php bin/magento cache:clean
php bin/magento cache:flush

Revisit the url, and the homepage will work fine once again.

1

Home page 404 may be solve below way as per your Issue

Issue: Store Configuration

Your store configuration point to wrong CMS page. CMS Home page was deleted or recreated, or you were experimenting with single store / multistore. What you need to do is :

Login to admin>Navigate to Stores > Configuration>Select General > Web tab >open Default Pages section>Set correct value for CMS Home Page option

Option value can be overrides on different scope level.

Scope switch located in top left corner. It is recommended to check option value from the Store View scope.

flush the cache in System > Cache Management or via console command

Issues: URL Rewrite

Under certain circumstances product or category can have empty request_path value. To fix it:

login to your store database with any database manager ( like phpMyAdmin or HeidySQL ) check if you have any records with empty request path by running following & delete those entries. It can be done manually or with SQL

MySQL> SELECT * FROM url_rewrite WHERE request_path='';
MySQL> DELETE FROM url_rewrite WHERE request_path=''; 
MagentoCLi>php bin/magento c:f
0

In admin, go to set the page you want to show as homepage in Stores > Configuration > General > Web > Default Pages > CMS Home Page.

Remember to flush the cache in System > Cache Management > Flush Magento Cache.

2
  • have tried that, it doesnt work. the setting looks ok in database, but not sure how to debug which page it is looking for. also i can see the page that i choose, if i go it its url. Commented Jul 29, 2016 at 7:05
  • did you get a solution to this problem?
    – Tisch
    Commented Apr 12, 2017 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.