Wordpress menus and pages redirect to 404 content not found. How I fixed it.

TL;DR the PHP version was upgraded without my knowledge. I removed the upgrade reference in .htaccess (or downgraded it) to fix the problem.


 I found that all wordpress content on my site were suddenly redirecting to an empty content page (error 404). I had set all 404 to redirect to the home page so all links were redirecting to the home page.

This was alarming because I had not made any changes or updated the website. This was a cpanel hosting package.

Many searches online pointed me to the permalink options in the admin area but that did not resolve my problem. Also it was suggested the issue resided in the .htaccess file in my hosting. 

What I eventually did after the solution to the problem had eluded me for a whole day was to compare the current htaccess file with a backup htaccess file using a text comparison tool. I soon discovered my php had been upgraded to a higher version by my hosting provider without my being notified. I found this code in the HTACCESS file



# php -- BEGIN cPanel-generated handler, do not edit

# Set the “ea-php80” package as the default “PHP” programming language.

<IfModule mime_module>

AddHandler application/x-httpd-ea-php80___lsphp .php .php8 .phtml

</IfModule>

# php -- END cPanel-generated handler, do not edit


I replaced the HTACCESS file with the backup and all was well again. So basically reverting to the previous php version fixed the issue. 

I would however recommend that you consider this method a temporary solution as you would need to eventually upgrade to a newer php version eventually. At best, use this solution to buy time and then work on a staging site to ensure the site will not break when php is updated.

Comments

Popular posts from this blog

The Mysterious Subframe Bushings: When Your Vehicle Clunks And Swerves And You've Done It All With No Resolution.

Dusk To Dawn Photocell Wiring Guide - Automating Your Outdoor Light

Easy Step By Step Guide to Using Google NotebookLM - A Personalized Research Assistant.