Simple URL rewrite cuasing querystring rewrite issues?

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 2
Joined: 17 Apr 2012, 09:45

Simple URL rewrite cuasing querystring rewrite issues?

05 Jun 2012, 08:24

Hi there,

I am using the full version of ISAPI Rewrite 64 bit and I am hoping someone can help with me the following;

I have a number of rules set up that seem to be working OK (see below):

Code: Select all
RewriteBase /
RewriteCond %{REQUEST_METHOD} !^POST
RewriteCond %{QUERY_STRING} ^Headline=([^=&]+)&NewsID=([^=&]+)$
RewriteRule ^news\.asp$ news/%1/%2/? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^news/([^/]+)/([^/]+)/?$ news.asp?Headline=$1&NewsID=$2 [NC,L]


What I would like is to do the following:

1) Re-write "/news.asp" (no querystring values) to "/news/" and also include the reverse rule?
I have already tried (see code below), but it stops the rule above working?
Code: Select all
RewriteRule ^news\.asp$ /news [NC,R=301,L]
RewriteRule ^news/?$ news.asp? [NC,L]


How do I apply this simple rule without it affecting the one with querystring values in it?

2) I also want to rewrite the following URLs, NOT redirect?

/collection.asp?SpeciesID=123 --> /snakes
/collection.asp?SpeciesID=234 --> /spiders


Many thanks for help on this :)
Simon (Clearchannel)

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

Re: Simple URL rewrite cuasing querystring rewrite issues?

05 Jun 2012, 10:56

The following config should work without issues:

RewriteBase /
RewriteCond %{REQUEST_METHOD} !^POST
RewriteCond %{QUERY_STRING} ^Headline=([^=&]+)&NewsID=([^=&]+)$ [NC]
RewriteRule ^news\.asp$ news/%1/%2/? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^news/([^/]+)/([^/]+)/?$ news.asp?Headline=$1&NewsID=$2 [NC,L]

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^news\.asp$ /news/ [NC,R=301,L]
RewriteRule ^news/?$ news.asp [NC,L]

RewriteCond %{QUERY_STRING} ^SpeciesID=123$ [NC]
RewriteRule ^collection\.asp /snakes [NC,L]
RewriteCond %{QUERY_STRING} ^SpeciesID=124$ [NC]
RewriteRule ^collection\.asp /spiders [NC,L]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 24 guests