You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by James Moe <ji...@sohnen-moe.com> on 2011/07/23 21:07:24 UTC

[users@httpd] RewriteRule help

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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?

- -- 
James Moe
moe dot james at sohnen-moe dot com
520.743.3936
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk4rG+wACgkQzTcr8Prq0ZMnOQCdGkvyhWeHnKgVRa+IOYhxMSJz
dvsAn0ToSTHifGNOpXUuVAcQMa0jWQpV
=8xiV
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule help

Posted by James Moe <ji...@sohnen-moe.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

O>>  That does not change anything. Here is what I put in the CONF file:
>> 
>> <Directory /var/www/html>
> Directory is basically the same as htaccess.
> 
  Oh.
  My ISP has a rather restrictive approach to what can be modified in
<httpd.conf>. The virtualhost definitions are off limits. Adding
Directory rules are okay.

- -- 
James Moe
moe dot james at sohnen-moe dot com
520.743.3936
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk4tuoIACgkQzTcr8Prq0ZNf9ACeNYlgcnI5g95IzzVuJu+RUl+X
PesAn2Kkf0++PPYPC+MXtiw3cLw2Dt0d
=8t9X
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule help

Posted by Eric Covener <co...@gmail.com>.
On Sun, Jul 24, 2011 at 6:36 PM, James Moe <ji...@sohnen-moe.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 07/23/2011 12:26 PM, Eric Covener wrote:
>>> How do I get the redirection to occur before the non-secure
>>> authorization request?
>>>
>>
>> If you put the rules in virtualhost context instead of htaccess,
>> they'll be evaluated earlier.
>>
>  That does not change anything. Here is what I put in the CONF file:
>
> <Directory /var/www/html>

Directory is basically the same as htaccess.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule help

Posted by James Moe <ji...@sohnen-moe.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/23/2011 12:26 PM, Eric Covener wrote:
>> How do I get the redirection to occur before the non-secure 
>> authorization request?
>> 
> 
> If you put the rules in virtualhost context instead of htaccess, 
> they'll be evaluated earlier.
> 
  That does not change anything. Here is what I put in the CONF file:

<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.

- -- 
James Moe
moe dot james at sohnen-moe dot com
520.743.3936
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk4snooACgkQzTcr8Prq0ZOCiwCfTeYsNrD8THEjSCe7H/dZk8xF
0U0An3DW49+477M7sSnlOi/IZFAgGruY
=m0Um
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule help

Posted by Eric Covener <co...@gmail.com>.
>  How do I get the redirection to occur before the non-secure
> authorization request?
>

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

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org