httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stone, Timothy" <tst...@cityofhbg.com>
Subject RE: [users@httpd] seeking feedback on config + mod_rewrite v. mod_alias ? [SOLVED]
Date Thu, 23 Jan 2003 14:53:07 GMT
Just a followup note closing the post.

I have successfully tested the following configuration in a very simple test environment.

#### hosts file ####
127.0.0.1 localhost
127.0.0.1 test
127.0.0.1 test2

#### httpd.conf ####

...
ServerName localhost
...
Listen 80
...
NameVirtualHost *
...
<VirtualHost *>
	#inherit ServerName
     ServerAlias test test2
     RewriteEngine on
     RewriteCond %{HTTP_HOST} !localhost
     RewriteRule ^(.*)$ http://localhost$1 [R=permanent]
     RewriteLog /usr/local/apache/logs/rewrite_log
     RewriteLogLevel 0
</VirtualHost>

This reaches my desired result. The most efficent? I do not know. I did find that mod_alias
will not do this... From /Professional Apache 2.0/, "If we want to translate a URL into another
URL and then use the result in other translations (for instance, further aliases or <Location>
containers), Alias well not do this for us. We will need to use the RewriteRule directive
of mod_rewrite instead."

Thank you Peter Wainwright.

Warmest Regards,
Tim

> -----Original Message-----
> From: Stone, Timothy 
> Sent: Wednesday, January 22, 2003 12:21 PM
> To: users@httpd.apache.org
> Subject: [users@httpd] seeking feedback on config + mod_rewrite v.
> mod_alias ? [REPOST]
> 
> 
> List,
> 
> Okay... Thanks for the patience. Coffee in hand ;) I'm going 
> to try explaining the purpose of my post with more detail and 
> some added configuration information. Thanks in advance for 
> any comments and suggestions offered.
> 
> Here's my scenario:
> 
> I have two (2) machines listening on IPs in the following manner:
> 
> www0 - x.x.x.2
>        x.x.x.4
> 
> www1 - x.x.x.1
>        x.x.x.3
> 
> DNS is configured for round-robin load sharing as follows:
> 
> www.primaryName.com. IN A x.x.x.1
> www.primaryName.com. IN A x.x.x.2
> www.primaryName.com. IN A x.x.x.3
> www.primaryName.com. IN A x.x.x.4
> www.secondaryName.com. IN A x.x.x.1
> www.secondaryName.com. IN A x.x.x.2
> www.secondaryName.com. IN A x.x.x.3
> www.secondaryName.com. IN A x.x.x.4
> ...repeat 3x more for other domains ...
> 
> Each machine is running Apache 2.0.43:
> 
> ServerName www.primaryName.com:80
> 
> A single vhost is configured as follows:
> 
> #NameVirtualHost *
> 
> <VirtualHost x.x.x.N>
>     # N is equal to the second IP address of the machine.
>     # so for www0, N = 4.
>     #inherit from global config
>     ErrorLog logs/error_xN.log
> </VirtualHost>
> 
> To complete this setup, I want all of the answering domain 
> names to display in the client as "http://www.primaryName.com"
> 
> I'm intending to accomplish this in the global configuration with:
> 
> RewriteEngine on
> RewriteRule ^(.+)$ http://www.primaryName.com/$1 [R=permanent]
> 
> As I understand it this should work, but I have not tested it 
> in production. This RewriteRule should inherit to the vhost 
> as well, correct? And would it be better to use a negated rule...
> 
> RewriteRule ^!(http://www.primaryName.com) 
http://www.primaryName.com/$1 [R=permanent]

N.B. In rewriting this post I'm seeing something I did not before. The machine will answer
on the IPs it's configured to listen to regardless of the vhost I have defined. I believe
my original intention of the vhost was to separate the log files out for reporting purposes,
but have since merged all of the access_logs. I think merging the error_logs might be in order
as well.

It seems that I want to define a vhost that looks something like:

#Uncomment NVH and listen on all IPs
NameVirtualHost *

#This vhost listens by default
<VirtualHost *>
    #inherit from global config
    ServerAlias www.secondaryName0.com www.secondaryName1.com
    RewriteEngine on
    RewriteRule RewriteRule ^(.+)$ http://www.primaryName.com/$1 [R=permanent]
    RewriteLog /path/to/log/file
    #temporarily set verbose logging
    RewriteLogLevel 3
</VirtualHost>

Finally, I'm on the fence with using mod_rewrite because of perceived, and documented, overhead.
I think it best fits my scenario. However, I'm thinking that mod-alias might also work. I'm
seeking feedback so... can mod_alias do this without the overhead?

Looking forward to hearing from the experiences of others. Thanks in advance for all suggestions
and comments.


Warmest Regards,
Tim

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


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