httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Stone <cityli...@petmystone.com>
Subject [users@httpd] In Rewrite Loop -- please help
Date Wed, 10 Sep 2003 12:22:27 GMT
List,

I'm running Apache 2.0.46 on Windows 2000 SP 2.

I have five domains, all variations on a theme (all examples):

www.mycity.com
www.mycity.org
www.mycity.net
www.mycityevents.com
www.mycitystate.gov

All five domains are entered in DNS identically for round robin load 
sharing.

Currently, www.mycity.com, acts as the "primary" domain for all of these 
domains. So a client requesting .org|.net|.gov are immediately 
redirected  (R=permanent) to "dot-com" via a RewriteRule (conf follows) 
in a virtual host.

Now, it has been decided that the "dot-gov" address will act as the 
primary domain. It might seem as simple as editing the ServerName, 
ServerAlias and appropiate RewriteRule and RewriteConds, but alas, no. 
It sends me into a loop, which can be seen in the RewriteLog; it kills 
the client but, fortunately, Apache gracefully handles it (a recent fix 
in the 2.0.4x series I believe).

I edit the conf (shown below in "Broken, Loopy Conf") changing very 
little, it nearly amounts to:

s/city\.com/citystate\.gov/g

Both working and broken httpd.conf follow, edited of course. Any 
suggestions on what could be causing this loop would be very helpful. 
I'm too close at this point to see anything wrong I think.

***** WORKING CONF ****
# Section 1: Global Configuration

Listen 80

# Section 2: Main Server Configuration

...
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
...
ServerName www.mycity.com:80

# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client.  When set "On", Apache will use the value of the
# ServerName directive.
#
UseCanonicalName Off

### Section 3: Virtual Hosts

NameVirtualHost *

# main vhost
<VirtualHost *>
     ServerName www.mycity.com
     ServerAlias mycity.com  *.mycity.com

     DocumentRoot "C:/usr/local/apache2-01/htdocs/mycity"
     RewriteEngine on
     RewriteCond %{HTTP_HOST} !^www.mycity.com [nocase] [OR]
     #For internal use, prevents images from being blocked
     RewriteCond %{HTTP_HOST} !^10\.*
     RewriteCond %{HTTP_HOST} !^$
     RewriteRule ^/(.*) http://www.mycity.com/$1 [R=permanent]
     RewriteLog logs/rewrite.log
     RewriteLogLevel 0
</VirtualHost>

<VirtualHost *>
     ServerName www.mycityevents.com
     ServerAlias mycityevents.com  *.mycityevents.com
     DocumentRoot "C:/usr/local/apache2-01/htdocs/mycity"
     RewriteEngine on
     RewriteCond %{HTTP_HOST} ^www.mycityevents.com [nocase]
     RewriteRule ^/(.*) http://www.mycityevents.com/rec/ [R=permanent]
     RewriteLog logs/rewrite_rec.log
     RewriteLogLevel 9
</VirtualHost>


***** BROKEN, LOOPY CONF ****

* recall, i'm simply trying to change the rewrite rule, but I'm also 
changing the server name because this is now the "primary" domain.

### Section 1: Global Configuration

Listen 80

### Section 2: Main Server Configuration

...
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
...
ServerName www.mycitystate.gov:80

# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client.  When set "On", Apache will use the value of the
# ServerName directive.
#
UseCanonicalName Off

### Section 3: Virtual Hosts

NameVirtualHost *

<VirtualHost *>
     ServerName www.mycitystate.gov
     ServerAlias mycitystate.gov  *.mycitystate.gov

     DocumentRoot "C:/usr/local/apache2-01/htdocs/mycity"
     RewriteEngine on
     RewriteCond %{HTTP_HOST} !^www.mycitystate.gov [nocase] [OR]
     #For internal use, prevents images from being blocked
     RewriteCond %{HTTP_HOST} !^10\.*
     RewriteCond %{HTTP_HOST} !^$
     RewriteRule ^/(.*) http://www.mycitystate.gov/$1 [R=permanent]
     RewriteLog logs/rewrite.log
     RewriteLogLevel 0
</VirtualHost>

<VirtualHost *>
     ServerName www.mycityevents.com
     ServerAlias mycityevents.com  *.mycityevents.com
     DocumentRoot "C:/usr/local/apache2-01/htdocs/mycity"
     RewriteEngine on
     RewriteCond %{HTTP_HOST} ^www.mycityevents.com [nocase]
     RewriteRule ^/(.*) http://www.mycityevents.gov/rec/ [R=permanent]
     RewriteLog logs/rewrite_rec.log
     RewriteLogLevel 0
</VirtualHost>




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


Mime
View raw message