WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. yifa
    Member
    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,

    Ben

    http://wordpress.org/plugins/simple-301-redirects/

  2. scottnelle
    Member
    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
    Member
    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.

    Thanks.

  4. patrickd
    Member
    Posted 3 months ago #

    yifa,

    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.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.