Re: mod_rewrite fails

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

 



I've tried dozens of iterations of rules, from simple like ^wp-login to much harder and more complex ones matching the whole address or only a part of one, it seems that i cant get any of them to work, either the rule will rewrite all the urls to http, or i get into an infinite redirect loop...

To answer your question that rule rewrites everything, even with wp-login in the name to http, seems to completely ignore that whole condition

I am not sure that REQUEST_URI always starts with a slash, because if you look at the 2.2 docu on apache.org or really anywhere else seems to do this just fine, eg (from: http://httpd.apache.org/docs/2.2/rewrite/rewrite_flags.html):
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.*) index.php?req=$1 [L]

Basically all i am trying to do is to rewrite all the urls going to our host, if coming from https to http, except for those going to a particular page (or a set of thereof), and ideally a rule that would rewrite http requests for those particular page(s) to https...

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

problem seems to be that i can do one, or the other, but cant figure out a way to do both at the same time... tried skip conditions, tried different regex approaches, it would be easier with a directory...

All of this is in the htaccess context.



Thank you

On 18/10/10 2:00 PM, Eric Covener wrote:
On Mon, Oct 18, 2010 at 1:43 PM, James Jones<james@xxxxxxxxxxxxxxxx>  wrote:
can someone explain why neither of these rules work:
Without a rewritelog or a description of what URL is/is-not rewritten
as you expect, it will be difficult.

What context are your rules in?  htaccess,<Directory>,<VirtualHost>  ?

Rule 1:
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^(.*)(?!wp-login) [NC]
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L]
Aside from being overly complicated, does this rewrite too much or too little?


Rule 2:
RewriteCond %{REQUEST_URI} ^wp-login(.*)$
REQUEST_URI always begins with a slash so the rest of this is a no-op.

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


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