WordPress.org

Ready to get started?Download WordPress

Forums

redirecting old query-string requests (5 posts)

  1. Cailean
    Member
    Posted 7 years ago #

    I switched to permalinks (finally) after several months running on the query-string. Everything works fine, but the search engines now have my site double-indexed... all my permalinks and all my querystring URLs...

    I want to intercept any request that has a querystring containing 'p' or 'page_id' parameters and serve up a 404 header (probably by 301-ing to ?error=404) - but only to the search engines...

  2. Cailean
    Member
    Posted 7 years ago #

    I think I sorted it out... so far, this has the intended results:

    RewriteCond %{HTTP_USER_AGENT} (msnbot|slurp|Googlebot|gigablast) [NC]
    RewriteCond %{QUERY_STRING} (p=[0-9]+|page_id=[0-9]+) [NC]
    RewriteRule ^.*$ /index.php?error=404 [R=301,L]

  3. davidchait
    Member
    Posted 7 years ago #

    well, that'll work fine -- if you don't mind killing your pagerank. 404s will nuke the original pages and their pagerank, whereas a 301 to the new permalinks could be done and retain pagerank for all existing pages.

    if you don't have real pagerank, or don't care, yeah the 404 is a dirty-hack substitute. ;)

    -d

  4. Cailean
    Member
    Posted 7 years ago #

    I'm more worried about dupe-content than pagerank at this point, but thanks for the heads-up...

    I'm not actually sure what the clean way would be...

    I can't 301 to the appropriate post/page because the querystring is by ID and my permalinks are by postname...

    also, the SE's already have all the permalink versions indexed, so I really just need to clean out the old pages that still work but I don't want them indexed...

  5. Cailean
    Member
    Posted 7 years ago #

    for everyone else's benefit, it just occured to me that it's probably better not to 301 to the error page, just rewrite - if an SE gets a 301 to a 404, it might just ignore the 301 not un-index the orig. page...
    So the last line would then be:
    RewriteRule ^.*$ /index.php?error=404 [L]

Topic Closed

This topic has been closed to new replies.

About this Topic