DevHeads.net

RewriteRule help

Hello,
This rule works, mostly. It is in the .htaccess file of the DocumentRoot.

RewriteEngine On
RewriteCond %{REQUEST_URI} =/teachers/ [OR]
RewriteCond %{REQUEST_URI} =/gated-bm/
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R]

Where it fails is the </gated-bm/> page. That directory also has a
.htaccess file which requires a username/password to view the page.
What happens is that the authorization is triggered first before the
redirection to https. After entering the user/pass, the redirection
occurs and another authorization request pops up.

How do I get the redirection to occur before the non-secure
authorization request?

Comments

Re: RewriteRule help

By Eric Covener at 07/23/2011 - 14:26

If you put the rules in virtualhost context instead of htaccess,
they'll be evaluated earlier.

Re: RewriteRule help

By James Moe at 07/24/2011 - 17:36

On 07/23/2011 12:26 PM, Eric Covener wrote:
<Directory /var/www/html>
RewriteEngine On
RewriteCond %{REQUEST_URI} =/teachers/ [OR]
RewriteCond %{REQUEST_URI} =/gated-bm/
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R]
</Directory>
<Directory /var/www/html/gated-bm>
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R]
</Directory>

The non-secure authentication request still pops up first.

Re: RewriteRule help

By Eric Covener at 07/24/2011 - 17:55

Directory is basically the same as htaccess.

Re: RewriteRule help

By James Moe at 07/25/2011 - 13:48

O>> That does not change anything. Here is what I put in the CONF file: