[SATLUG] mod_rewrite and apache
robertc3
robertc3 at hotmail.com
Tue Jan 31 22:34:07 CST 2006
> On Wednesday 01 February 2006 7:27 am, robertc3 wrote:
>> I'm trying to redirect users from using http to using https on two
>> subdirectories on my web server.
>>
>> Here's what I have in my httpd.conf so far:
>>
>> RewriteEngine On
>> RewriteCond %{SERVER_PORT} !^443$
>> RewriteRule ^/sc(.*)$ https://%{SERVER_NAME}/sc$1 [L,R]
>> RewriteRule ^/internal(.*)$ https://%{SERVER_NAME}/internal$1 [L,R]
>>
>> The first one (sc) works fine. All subdirectories get redirected as
>> well. The second one (internal) doesn't work and produces the
>> "Redirection Limit Exceeded" message in Firefox (IE just keeps trying).
>>
>
> The problem is that when you set a RewriteCond, only the next RewriteRule
> applies.
>
> To fix it you could either repeat the RewriteCond before the second rule,
> or do something tricky like:
>
> RewriteCond %{SERVER_PORT} ^443$
> RewriteRule .* - [S=2]
> RewriteRule ^/sc(.*)$ https://%{SERVER_NAME}/sc$1 [L,R]
> RewriteRule ^/internal(.*)$ https://%{SERVER_NAME}/internal$1 [L,R]
>
> Which is saying if the condition matches, skip the next 2 rules.
>
>
> Julian.
Julian,
I added the
RewriteRule .* - [S=2]
and still no luck. I also tried adding the RewriteCond rule but I still get
the "Redirection Limit Exceeded" message. Any other suggestions?
Robert
More information about the SATLUG
mailing list