Help Creating a Rewrite Condition

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


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-25-2007
jeremy.parrott@gmail.com
 
Posts: n/a
Default Help Creating a Rewrite Condition

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.

  #2 (permalink)  
Old 01-25-2007
Jim Hayter
 
Posts: n/a
Default Re: Help Creating a Rewrite Condition

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:24 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0