Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )

I have updated my permalink structure to /archive/%post_id%, but if someone uses a URL like /archive/456857 instead of the full URL of /blog-test, WordPress shows the post without giving a 301 to the full URL. Isn’t this poor SEO? Sites like tumblr and stackexchange automatically send a 301 to the full URL. Any hacks/code/plugins/settings/etc to fix this?

/archive/456857 does get a 301 to /blog-test but /archive/456857 does not and ends up in two separate URLs to the same content.

Read More

My permalink structure is /archive/%post_id%.

Related posts

Leave a Reply

2 comments

  1. Some things in your post are still unclear, but if it’s only the SEO you are worrying about, you can set a canonical tag in your header, referencing always the correct post_name url:

    <?php if(is_singular()){
    echo '<link rel="canonical" href="'.get_permalink().'" />';
    } ?>
    

    That way you’re telling the search engines where the original post is.

  2. The question is, how many URLs of the structure,

    /archive/%post_id%
    

    …exist as either indexed pages within search engines or as external back links from other sites?

    You see, just because you can access a URL from two different formats, ID or slug, doesn’t mean your SEO would be effected necessarily.

    If you have links in the SERPs or external to your site that now exist under a different URL structure you can use a plugin like, http://wordpress.org/extend/plugins/simple-301-redirects/ to help you with 301 redirects.

    Although WordPress internal rewrite rules should handle this for you automatically when you have a custom permalink structure set.

    You could go beyond this and create your own special rewrite rules, but lets not jump into regex and all that if we don’t have to when the above plugin might be enough.

    By the way this doesn’t make sense,

    p.s. /archive/456857 does get a 301 to /blog-test but /archive/456857
    does not and ends up in two separate URLs to the same content.