Fix missing trailing slash
4 posts
• Page 1 of 1
Fix missing trailing slash
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.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Fix missing trailing slash
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
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
Re: Fix missing trailing slash
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.
Thanks for your reply. So those question marks are not operators but literal characters. I am not really an expert with regular expressions.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Fix missing trailing slash
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
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
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests