Re: mod_rewrite fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux