IONICS ISAPI (IIRF) Rewrite Exclusions
I'm a novice at regular expressions and ISAPI redirects. I am using the
IIRF ISAPI rewrite filter found here http://iirf.codeplex.com/. This is
what I want to do:
Specify a directory in which all* HTTP requests are redirected to HTTPS
*Exclude a subdirectory, or specific file, from that redirection
For example, I may want http://www.mysite.com/example/ to redirect to
https://www.mysite.com/example/, and also
http://www.mysite.com/example/foo/, http://www.mysite.com/example/bar/,
etc. - all redirect to https://www.mysite.com/example/foo/ and so forth.
However, I may want http://www.mysite.com/example/cat/ NOT to redirect to
https://www.mysite.com/example/cat/, nor its child sub-directory
http://www.mysite.com/example/cat/food/.
The redirect I'm using looks like this:
RewriteCond %{SERVER_PORT} ^80$
RedirectRule ^/(example/.*) https://%{HTTP_HOST}/$1 [R=301]
And it seems to be working as expected - no problems there. According to
this example
(http://iirf.codeplex.com/wikipage?title=Exclude1&referringTitle=Examples),
there's a special rewrite character in IIRF, -, which tells the filter to
do nothing. There is also a flag, [L], which tells the filter that the
preceding rule is the last rule for that request, and to ignore any
following rules which also match.
So I have another redirect which looks like this:
RedirectRule (.*)/cat/(.*)$ - [L]
And so my iirf.ini file looks like this:
#Exclusions
RedirectRule (.*)/cat/(.*)$ - [L]
#Redirects
RewriteCond %{SERVER_PORT} ^80$
RedirectRule ^/(example/.*) https://%{HTTP_HOST}/$1 [R=301]
The HTTPS redirection is working fine. The excluded URLs, though, aren't
working - they get caught in a redirection loop. If I remove the HTTPS
redirect, then the exclusions work fine. Why is this happening? Am I
misunderstanding the way that the [L] flag works?
Thanks!
No comments:
Post a Comment