Rewrite to static page based on query string value

CLOSED

Rewrite to static page based on query string value

Postby jelo » Mon Feb 01, 2010 4:22 pm

Hi,

I have a bunch of URLs like this:
www.domain.com/path/file.asp?display=#

RewriteCond %{REQUEST_URI} ^/path/file\.asp$
RewriteCond %{QUERY_STRING} ^display\=(.*)
RewriteRule ??

How do specify the rewrite rule to just compare the value of the display variable and to do the redirect, e.g.

www.domain.com/path/file.asp?display=1 forward to www.newsite.com/staticpage.html
www.domain.com/path/file.asp?display=2 forward to www.newsite.com/anotherstaticpage.html

Any help would greatly be appreciated. I tried out several different ways already and it does not work...

Thanks, Jelo
jelo
 
Posts: 2
Joined: Mon Feb 01, 2010 4:06 pm

Clarification

Postby jelo » Mon Feb 01, 2010 5:19 pm

Just to clarify, I understand that I could do it like this:

RewriteCond %{QUERY_STRING} ^display\=1
RewriteRule ^(.*)$ http://www.newsite.com/staticpage.html
RewriteCond %{QUERY_STRING} ^display\=2
RewriteRule ^(.*)$ http://www.newsite.com/anotherstaticpage.html

But then I would need 2 lines for each URL to rewrite. I am trying to set the condition once and then just compare the values if possible to make it shorter.

By the way: how do I specify that a condition applies to the next x rules and not only to the next one? For example if I do not want to rewrite every query string variable display, but just the ones with the file name
RewriteCond %{REQUEST_URI} /file.asp

Would I need to repeat these 2 conditions for each rule?

Thanks, Jelo
jelo
 
Posts: 2
Joined: Mon Feb 01, 2010 4:06 pm


Return to New Threads/Problems

Who is online

Users browsing this forum: No registered users and 18 guests

cron