This is a discussion on Help Creating a Rewrite Condition within the Apache Web Server forums, part of the Web Server and Related Forums category; I have minimal knowledge on apache or making configuration changes, so if you could reply and break it down Barnie ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have minimal knowledge on apache or making configuration changes, so
if you could reply and break it down Barnie style I would appreciate it. Here's the problem. I had a simple redirect on my web site that would send everyone going to http://mysite.com to https://mysite.com and it worked great, but if someone were to type in http://mysite.com/listing then they would not get redirected to the https site. >From this we created a rewrite rule that looked like this (if there's anything wrong with this, please let me know): RewriteCond %{REMOTE_HOST} !^IPADDRESSOFSERVER/$ RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 <https://%{HTTP_HOST}/$1>[NC,R,L] This seems to be working for site requests, but what we need to accomplish is have all users get redirected to the https site except for the local host. The local host still needs to communicate on port 80 for some web features, but isn't able to with what we have in place. (Should IPADDRESSOFSERVER be localhost, 127.0.0.1, or the actual IP of the Server?) If anybody has any suggestions on how to get this working please let me know. |
|
|||
|
jeremy.parrott@gmail.com wrote:
> I have minimal knowledge on apache or making configuration changes, so > if you could reply and break it down Barnie style I would appreciate > it. > > Here's the problem. I had a simple redirect on my web site that would > send everyone going to http://mysite.com to https://mysite.com and it > worked great, but if someone were to type in http://mysite.com/listing > then they would not get redirected to the https site. > >>From this we created a rewrite rule that looked like this (if there's > anything wrong with this, please let me know): > > RewriteCond %{REMOTE_HOST} !^IPADDRESSOFSERVER/$ > RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 > <https://%{HTTP_HOST}/$1>[NC,R,L] > > This seems to be working for site requests, but what we need to > accomplish is have all users get redirected to the https site except > for the local host. The local host still needs to communicate on port > 80 for some web features, but isn't able to with what we have in place. > (Should IPADDRESSOFSERVER be localhost, 127.0.0.1, or the actual IP of > the Server?) > > If anybody has any suggestions on how to get this working please let me > know. > Try using %{REMOTE_ADDR} to get the IP address. What you test it against depends on how the server accesses itself (what URL) and what IP address that name resolves to on that server. If the URL is <hostname>/..., try 'nslookup <hostname>'. That should show you the IP address you are connecting to. Or you could add multiple RewriteCond statements, one per possible IP to exempt. HTH, Jim |