Magento Home Page Returns 404 Status Code

by Scott Hebert

Magento logo -leftNaturally, I ran into this problem in the middle of the night when the client was asleep and I had no access to the Magento administrative interface. The short story is that after running a re-index of the site, the home page began returning a 404 error status. A bit of Googling indicated we were likely running into a problem where something had an empty URL rewrite that caused the home page to rewrite to a non-existant page. Due to client privacy concerns, I cannot just copy and paste the SQL queries I ran along with their output, but I will provide what I can.

First, I had to find the URL rewrite that had an empty request path. This is the one that was causing the trouble.

At first, I just tried to add a request path. Unfortunately, a foreign key constraint was causing me issues (ERROR 1451).

So, I decided to remove the other end of the foreign key so that I could update this row and get the site fully functional again.

After that I had to clear the Magento full page cache in order to get the home page working again. This site uses file storage for sessions and caching, so I just had to rm -rf var/full_page_cache (in the Magento top-level directory).