httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Covener <cove...@gmail.com>
Subject Re: [users@httpd] mod_rewrite fails
Date Mon, 18 Oct 2010 20:13:03 GMT
> everything going to https://somesite.com needs to go to http://somesite.com
> so for example https://somesite.com/somedir/somefile.php?somevar=someval
> needs to be redirected to
> http://somesite.com/somedir/somefile.php?somevar=someval
> and that is true except for when goint to say
> http://somesite.com/login.php?somevar=someval, in which case that needs to
> be redirected to https://somesite.com/login.php?somevar=someval or similarly
> if it goes to https already, it needs to stay https...

I ignored the query string stuff you had, it's easy enough to add back
in if you meant for it to be significant.

in docroot htaccess:

  RewriteEngine on
  RewriteBase /

  RewriteCond %{HTTPS} =on
  RewriteRule ^(?!login.php$) http://%{HTTP_HOST}%{REQUEST_URI}

  RewriteCond %{HTTPS} !=on
  RewriteRule ^login.php$ https://%{HTTP_HOST}%{REQUEST_URI}

$ wget --no-check-certificate https://localhost/login.phpa.html 2>&1 | grep Loc
Location: http://localhost/login.phpa.html [following]
$ wget --no-check-certificate https://localhost/foo 2>&1 | grep Loc
Location: http://localhost/foo [following]
$ wget --no-check-certificate https://localhost/barlogin.php 2>&1 | grep Loc
Location: http://localhost/barlogin.php [following]
$ wget --no-check-certificate https://localhost/login.php 2>&1 | grep Loc
$

$ wget http://localhost/login.php 2>&1 | grep Loc
Location: https://localhost/login.php [following]
$ wget http://localhost/other.php  2>&1 | grep Loc
$
$ wget http://localhost/otherlogin.php  2>&1 | grep Loc
$
$ wget http://localhost/foo  2>&1 | grep Loc
$

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


Mime
View raw message