Archived topic
How do I return the correct HTTP status code for a 404 error page?
4 replies · Started by Yurik on February 19, 2021
Hi,
for some reason (I can't find why and how to enable), on my website any time if I'm trying to access no existing pages/urls - it just redirects to the main page and gives the Status code 200 instead 404.
Please can you help and advice how I should configure Wordpress and Template to return the correct HTTP status code (404) and display the 404 page (Oops! That page can’t be found)?
Many thanks
Bets Regards
Hi there,
that should be the default behaviour.
Things to check for:
Server config - for example HTTAccess.
Cache Plugins - that may be affecting the 404 return.
Redirect plugins or scripts.
Hi David,
Thanks for reply!
Server config – for example HTTAccess.- Checked and asked hosting provider to review. There is nothing unusual and all looks correct
Redirect plugins or scripts. - Never used or added any of these. Should not be a matter in this case
Cache Plugins – that may be affecting the 404 return. - Recently swap to WP Rocket, therefore I can presume that this plugin could cause this problem, but I've tried to switch it off, and it still redirects to main page within status code 200.
I understand that this is nothing to do with the theme, but please could you give me some advice how I should action?
Many thanks
Best regards
Hi David,
I found the problem! This time it was the SEO plugin, where it was set up (default), redirection to main page, and so gives the Status code 200 instead 404.
By modifying this, now it redirects to 404 page and gives the correct status code 404.
Amen!)
Best Regards
Glad to hear you found the issue!