Welcome to WebmasterWorld Guest from 54.166.54.215

Forum Moderators: Ocean10000 & incrediBILL & phranque

301 redirect but not passing variables

redirect all dynamic pages to one static page

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

10+ Year Member



Hi,

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 Sep 15, 2009 (gmt 0)

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



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]

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

10+ Year Member



That worked just fine, many many thanks!
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month