Title: redirecting old query-string requests
Last modified: August 18, 2016

---

# redirecting old query-string requests

 *  [cailean](https://wordpress.org/support/users/cailean/)
 * (@cailean)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/redirecting-old-query-string-requests/)
 * 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…

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [cailean](https://wordpress.org/support/users/cailean/)
 * (@cailean)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/redirecting-old-query-string-requests/#post-425217)
 * 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]
 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/redirecting-old-query-string-requests/#post-425235)
 * 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
 *  Thread Starter [cailean](https://wordpress.org/support/users/cailean/)
 * (@cailean)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/redirecting-old-query-string-requests/#post-425308)
 * 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…
 *  Thread Starter [cailean](https://wordpress.org/support/users/cailean/)
 * (@cailean)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/redirecting-old-query-string-requests/#post-425354)
 * 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]`

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘redirecting old query-string requests’ is closed to new replies.

## Tags

 * [htaccess](https://wordpress.org/support/topic-tag/htaccess/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [cailean](https://wordpress.org/support/users/cailean/)
 * Last activity: [19 years, 10 months ago](https://wordpress.org/support/topic/redirecting-old-query-string-requests/#post-425354)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
