Ready to get started?Download WordPress


Simple 301 Redirects
[resolved] How do I redirect all non-existent URL's to the homepage? (4 posts)

  1. yifa
    Posted 5 months ago #

    Hi there,

    I have an eCommerce website and I have hundreds of old product that are no longer existent, but I'm getting errors for them all (according to my SEO guy, and he advises that I need to redirect them).

    How can I redirect all non-existent URL's to my homepage? Is there one easy step for this, or do I have to find out each and every URL?

    Thanks in advance,



  2. scottnelle
    Plugin Author

    Posted 5 months ago #

    I'm afraid my plugin isn't set up to redirect all broken links to the home page, but here's a method to do it:

    1. Edit (or create) 404.php in your theme.
    2. Replace everything in 404.php with the following:

    <php wp_redirect(site_url(), 301); exit(); ?>

  3. yifa
    Posted 5 months ago #

    Do I have to replace site_url with my actual url? And will this help with SEO to get rid of these 301 errors?

    As you can tell, I'm not very knowledge on this stuff.


  4. patrickd
    Posted 3 months ago #


    You do not have to replace site_url with your actual URL. site_url() is a WordPress function that returns the actual URL of your site.

    A 301 is the code for a redirect and is not an error. I assume you meant 'will getting rid of the 404s help with SEO'? There seems to be some debate on this topic but the short answer is yes ...and no. Google will not penalize you for having 404 errors but you may want to 301 some of those 404s if they are getting a lot of links and traffic.


You must log in to post.

About this Plugin

About this Topic


No tags yet.