Redirect based on query string value

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 13 Jun 2013, 05:54

Redirect based on query string value

13 Jun 2013, 05:57

Hi,

I would like to create a redirect based on a query string value of "page=19304" or "page=832".

For example, would like to redirect http://www.domain.org.uk?page=19304 or http://www.domain.org.uk/test/news.aspx?page=19304 to another page like http://www.domain.org.uk/help.aspx

I have created and tested the following regular expression on a development machine and seems to work:

RewriteCond %{HTTP_HOST} ^(?:www\.)domain\.org\.uk$ [NC]
RewriteCond %{QUERY_STRING} ^page=19304$ [NC]
RewriteRule .* http://www.domain.org.uk/help.aspx [NC,R=301,L]


I was wondering if anyone could see any errors or suggestions to improve this regular expression?

Thanks

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Redirect based on query string value

13 Jun 2013, 10:01

Hello,

Your rules look absolutely fine. But here are some tiny fixes:

RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.org\.uk$ [NC]
RewriteCond %{QUERY_STRING} ^page=19304$ [NC]
RewriteRule .? http://www.domain.org.uk/help.aspx? [NC,R=301,L]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 13 guests