Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies

IIS Isapi URL rewrite problem

Problems with URL rewriting



4:23 pm on Jan 7, 2009 (gmt 0)

5+ Year Member

I am trying to rewrite dirty URLs to tidy ones in the interest of good SEO.
I am on a windows server which has ISAPI URL rewrite installed which allows you to use a .htaccess file.
I have tried in vain to change the following URL using the rewrite rule below but it wont have it. I have tried several permutations but still no luck.


RewriteEngine on
RewriteRule ^/used/car/used/?([^/]*)$ /used/car.asp?used=$1 [L]

The URL rewrite works fine because:
RewriteEngine on
RewriteRule ^(.*?\.asp)/([^/]*)/([^/]*)(/.+)? $1$4?$2=$3 [NC,LP,QSA]
works fine, but I have to leave the .asp in the URL like this
I am trying to shift the .asp and be able to modify my own rules.
Thanks for any help

[edited by: coopster at 1:49 pm (utc) on Jan. 15, 2009]
[edit reason] please use example.com, thanks! [/edit]


6:38 pm on Jan 7, 2009 (gmt 0)

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

Are you sure that the requested URL-path as seen by RewriteRule in .htaccess will start with a slash? On Apache, URLs seen by a RewriteRule in example.com/.htaccess do not start with a slash, as it is stripped off when the requested URL-path is "localized" to the per-directory .htaccess context (i.e. the location of this .htaccess file is *in* "/", so it is removed from the localized request URL-path). However, I'm not sure if ISAPI Rewrite acts the same.

However, if this is also the case with ISAPI Rewrite, then your original rule works because it matches "^(.*?\.asp)" at the beginning of the requested URL-path, so it doesn't care if there is a leading slash or not.

Also, what is the "/?" following "used/cars/used" for? This makes that trailing slash optional. That, and the following "([^/]*)$" subpattern mean that your rule will accept a blank value for "used=". It also means that the same content will be served for

and for


This creates duplicate-content problems -- the same content accessible at more than a single, canonical URL.

Is that what you intended?

If this were Apache, I'd suggest:

RewriteEngine on
RewriteRule [b]^us[/b]ed/car/used/([^/]*)$ /used/car.asp?used=$1 [L]

Requested URLs matching ^used/car/used([^/]*)$ (no slash after "used") should be 301-redirected to example.co.uk/used/cars/used/$1 to prevent this problem.



5:51 am on Jan 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Is this Isapi rewrite 2 or 3?

I'm guessing 3 as 2 doesn't use .htaccess, it uses httpd.ini.


8:20 am on Jan 8, 2009 (gmt 0)

5+ Year Member

It is Isapi 3.

Thanks for the detailed reply Jim.
Your suggestion didn't work but I did neglect to give you some info that could make a difference - the .htaccess file resides in the "used" folder with car.asp file.

[edited by: BBonanza at 8:23 am (utc) on Jan. 8, 2009]


9:18 am on Jan 8, 2009 (gmt 0)

5+ Year Member

Another Question: Once I have set up the rewrite how do I go about 301 redirecting


Can this be done in the .htaccess file?

Sorry, I am new to this, and to be honest it is quite tough to get my head around - a digit in the wrong place and you get a big "Family Fortunes" NA NAAAAAA.
Thanks Guys


11:00 am on Jan 8, 2009 (gmt 0)

5+ Year Member

I have now place my .htaccess in the root folder.
I have inserted this 301 redirect into the htaccess

RewriteCond %{QUERY_STRING} ^make=(.+)$
RewriteRule ^oldfolder/oldpage.asp$ http://www.example.co.uk/used/car.asp/used/%1 [L,R=301]

It does redirect, but it resolves this:


It needs to be:



[edited by: coopster at 1:48 pm (utc) on Jan. 15, 2009]
[edit reason] please use example.com, thanks! [/edit]


11:18 am on Jan 8, 2009 (gmt 0)

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

BBonanza, have you tried the ISAPI_Rewrite forums for assistance with this? Yaroslav and crew over there at Helicon Tech are on the ball and will usually respond within 24 hours with an appropriate solution based on your requirements.

Since you are using the .htaccess method I'm going to assume that what jdMorgan is providing as examples should take care of ya.


8:34 pm on Jan 14, 2009 (gmt 0)

5+ Year Member

Hello BBonanza,

I have done similar rewrite with ISAPI 3 and I would advise the following:

1)On the portion of your rule that has %1 change it to $1

2)On the clean url, escape the back-slash / and periods . with a forward-slash \

3) Change [L,R=301]to [R=301,L] so that it first redirects to the new url and then stops looking for a match.

4)Update to the latest release of ISAPI 3 (this version has had several updates since its first release)

So change it from this:

RewriteCond %{QUERY_STRING} ^make=(.+)$
RewriteRule ^oldfolder/oldpage.asp$ http://www.example.co.uk/used/car.asp/used/%1 [L,R=301]

To this:

RewriteCond %{QUERY_STRING} ^make=(.+)$
RewriteRule ^oldfolder\/oldpage\.asp$ http://www.example.co.uk/used/car.asp/used/$1 [R=301,L]

Hope this helps!


[edited by: coopster at 1:47 pm (utc) on Jan. 15, 2009]
[edit reason] please use example.com, thanks! [/edit]


Featured Threads

Hot Threads This Week

Hot Threads This Month