homepage Welcome to WebmasterWorld Guest from 54.166.53.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
301 redirect but not passing variables
redirect all dynamic pages to one static page
AnonyMouse

10+ Year Member



 
Msg#: 3989647 posted 11:15 am on Sep 15, 2009 (gmt 0)

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!

 

jdMorgan

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



 
Msg#: 3989647 posted 3:45 pm on Sep 15, 2009 (gmt 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]

Jim

AnonyMouse

10+ Year Member



 
Msg#: 3989647 posted 5:24 pm on Sep 15, 2009 (gmt 0)

That worked just fine, many many thanks!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved