|
Home > Archive > Apache Server configuration support > January 2007 > Help Creating a Rewrite Condition
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Help Creating a Rewrite Condition
|
|
| jeremy.parrott@gmail.com 2007-01-25, 1:21 pm |
| 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.
| |
| Jim Hayter 2007-01-25, 1:21 pm |
| 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.
>
> 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
|
|
|
|
|