Only redirect when not in a certain folder ?
2 posts
• Page 1 of 1
Only redirect when not in a certain folder ?
Hi all,
I am trying use rewrite rules to remove any trailing slashes but only for certain folders on my site. This is because some folders (3rd party software on the site) require trailing slashes and so my rule sends browsers into a redirect loop when these folders are accessed.
Currently I have the following:
If I take the RewriteCond line out, then the trailing slashes are removed correctly but browsing to the /icm folder goes into a redirect loop. However, if I leave the RewriteCond line the rule is ignored for everything.
The ISAPI 2 documentations states that "RewriteCond URL /icm.*" can be used to apply a rule just in the icm folder (and subfolders) so is it a case of the ! directive not working for RewriteCond ?
Anyone got any ideas ?
Regards,
Adam Brunt
I am trying use rewrite rules to remove any trailing slashes but only for certain folders on my site. This is because some folders (3rd party software on the site) require trailing slashes and so my rule sends browsers into a redirect loop when these folders are accessed.
Currently I have the following:
### make sure all URLs don't have a trailing slash
RewriteCond URL !^/icm.*
RewriteRule ^([^.?]+[^.?/])/((/|\?|\&).*)?$ $1$2 [RP,L]
If I take the RewriteCond line out, then the trailing slashes are removed correctly but browsing to the /icm folder goes into a redirect loop. However, if I leave the RewriteCond line the rule is ignored for everything.
The ISAPI 2 documentations states that "RewriteCond URL /icm.*" can be used to apply a rule just in the icm folder (and subfolders) so is it a case of the ! directive not working for RewriteCond ?
Anyone got any ideas ?
Regards,
Adam Brunt
Re: Only redirect when not in a certain folder ?
Hello, Adam
The issue is that negation in ISAPI_Rewrite won't work like this.
Try to use the following rule instead:
### make sure all URLs don't have a trailing slash
RewriteRule /(?!icm.*)([^.?]+[^.?/])/((?:\?|&).*)?$ $1(?2$2) [RP,L]
The issue is that negation in ISAPI_Rewrite won't work like this.
Try to use the following rule instead:
### make sure all URLs don't have a trailing slash
RewriteRule /(?!icm.*)([^.?]+[^.?/])/((?:\?|&).*)?$ $1(?2$2) [RP,L]
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 9 guests