Fix missing trailing slash

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 2
Joined: 03 May 2012, 12:31

Fix missing trailing slash

03 May 2012, 14:03

In the examples section on this site (http://www.helicontech.com/isapi_rewrit ... amples.htm) you can find a rule that fixes a missing trailing slash:

RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

Somewhere else I found a similar rule:

RewriteRule ^([^.]+[^/])$ http://example.com/$1/ [R=301,L]

Can someone tell what the difference is? Actually I don't really understand the quantifiers (?) in the first example.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Fix missing trailing slash

04 May 2012, 07:40

Hello,

The difference is in the versions of ISAPI_Rewrite. ISAPI_Rewrite 2 used to include querystring parameter, so the first rule excluded everything before the '?'.
The second rule is for ISAPI_Rewrite 3. It doesn't have querystring matching in the rule, querystring is separated to a different condition.

Regards
Andrew

User avatar
Posts: 2
Joined: 03 May 2012, 12:31

Re: Fix missing trailing slash

04 May 2012, 14:38

Hello Andrew,

Thanks for your reply. So those question marks are not operators but literal characters. I am not really an expert with regular expressions.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Fix missing trailing slash

07 May 2012, 07:34

NO.

You need to know that there's been a great difference made between v2 and 3 in the matter of syntax. In v2 '?' was a character, in v3 it's a separater between querystring and URL or a logic operator, but not a character

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 4 guests