View Single Post
  #10 (permalink)  
Old 10-14-2008, 10:34 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,661
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

As far as I can tell, the only way to do this reliably is with mod_rewrite, as Dave showed above. I would just alter that code slightly so that it should work for any page on your site. I think the following should work:

Code:
RewriteCond %{QUERY_STRING} ref=pislikcs.com 
RewriteRule ^(.*).html$ http://example.com/%1.html [R=301,L]


This should take the entire URL up to the .html extension and replace it in a redirect without a query string. The rewriteCond directive should ensure this is only done for ref=pislikcs.com so that other query strings on your site will still work.
__________________
The best way to learn anything, is to question everything.
Reply With Quote