Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

301 redirect but not passing variables

redirect all dynamic pages to one static page

11:15 am on Sep 15, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:May 13, 2003
posts: 151
votes: 0


As per a previous post from 2007 (http://www.webmasterworld.com/apache/3245421.htm), I'm trying to redirect all variations of previously dynamic page to one static page - without passing any variables. I.e. a many-to-one mapping.

If I do the following:
RewriteCond %{REQUEST_URI} ^/page.action
RewriteRule ^ http://www.example.com/newpage.html [R=301,L]

Then e.g. page.action?var=123 gets redirected to http://www.example.com/newpage.html?var=123
Is it possible to prevent those variables from being passed in the redirection?

Thanks in advance for any replies!

3:45 pm on Sept 15, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0

Delete the RewriteCond, move the URL-path to be matched to the RewriteRule pattern, and put a question mark on the end of the substitution URL. This question mark *will not* appear in the 'new URL,' but will serve to clear the current query string, which will otherwise be passed through the rule unchanged (which is the cause of your problem).

RewriteRule [b]^page\.action$[/b] http://www.example.com/newpage.ht[b]ml? [R[/b]=301,L]

5:24 pm on Sept 15, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:May 13, 2003
votes: 0

That worked just fine, many many thanks!