0

I want to redirect all 404 error pages on my WordPress site to the homepage, or to a specific page.
Any advice?

  • have u downvoted my question? do you know it's not your good answer. – Aadii Mughal Mar 25 at 19:28
  • i get it fixed by wordpress.org/plugins/all-404-redirect-to-homepage this plugin. – Aadii Mughal Mar 25 at 19:29
  • i get it fixed by wordpress.org/plugins/all-404-redirect-to-homepage this plugin. but i still want to use code instead of plugin. – Aadii Mughal Mar 25 at 19:29
  • 2
    Don't redirect 404 page to homepage. It's bad for SEO and it might remove information that could help you fix your links. Save yourself the trouble and just use the 404 page to find your errors and fix them. – keepkalm Mar 25 at 19:47
  • 2
    It's probably a better idea to design your 404 page to include relevant information from your homepage and/or include a link to your homepage. It can be confusing to users, and hurt your SEO / search engine ranking to blanketly redirect without sending a 404 code for non-existant pages. 404 error codes serve a useful purpose. If you do insist on doing so, you should, at a minimum, track these redirects, so that you can fix errors. This plugin that can do both Redirection. If you change the URL of a page, use it to redirect to your updated page. – SherylHohman Mar 25 at 20:02
1

It's probably a better idea to design your 404 page to include relevant information from your homepage and/or include a link to your homepage.

Simply redirecting all 404's to the home page can be confusing to users, and hurt your SEO / search engine ranking. It is suggested that you provide feedback to your users why a page they expected to see was not loaded. 404 error codes can serve a useful purpose.

If you do insist on doing blanket redirections, you should, at a minimum, track these redirects, so that you can fix errors.

This plugin that can do both Redirection, and more.

A great feature of this plugin, is that if you change the URL of a page within your site, you can specify a "permanent" redirect to the new proper home of your page.

If you monitor the 404's on your website, you can also identify mistakes, such as a typo in your html, that may be producing an unintended 404. You can then both fix the typo, and add a specific redirect to forward any requests for that mistyped link, to redirect to the correct url. Then visitors, whether using either link will arrive on the intended page.

You can also use the log to identify spelling mistakes that originate from typos on other sites linking to yours. Again, you can add a specific redirect that intercepts the typo and forwards them to the proper page. You could even try emailing them to inform them of their typo. They may or may not fix it, but either way, you are able to automatically direct users to the correct website.

Note, when you view the list of 404's logged by this (or any) plugin, you will see a ton of bad requests that are "bots" trying to find vulnerabilities in your website. These requests can either be ignored, redirected to a specific page (such as localhost, or your home page), or you can set a rule to kick them off your system after a certain number of bad requests.
For the most part, you will want to focus on 404's that are obviously the result of typos, or urls that once existed, but have either changed, or been removed altogether.

In the case of pages that have been deleted, then permanently redirecting those links to the home page may be the proper answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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