Forum Moderators: phranque

Message Too Old, No Replies

Need httpd.conf

         

tcomo

2:30 pm on May 27, 2005 (gmt 0)



Hello - and thanks for your time.

I'm looking for a suggested httpd.conf. I have two web sites up and running, both registered domains and both pointing to a fixed IP on a Windows XP box running off cable modem, using Apache 2.0.54 with Active State Perl. I'm good to go, except I'm not sure my httpd.conf is correctly configured. The primary site is www.example.net and the second site is www.example.com. One indication I may have a problem is that if you request http://example.com instead of http://www.example.com, it loads the primary site instead.

Here are the changes I made to the default httpd.conf (believe I've got everything here - I'm posting this from work and so from memory.) I'm just not sure about other directives, whether I've got sufficient security, whether my virtual host containers are incorrect, etc. What I'd prefer is if someone expert in httpd.conf could [post] a suggested httpd.conf for my particular situation or <snip>. I have made no changes to default modules.

ServerRoot "C:/Web/html"
Listen 24.158.119.26::80
DocumentRoot "C:/Web/html"
Directory "C:/Program Files/Apache Group/Apache2/htdocs"
ScriptAlias "C:/Web/cgi-bin/"

<VirtualHost *:80>
ServerName www.example.net
DocumentRoot C:/Web/html
</VirtualHost>

<VirtualHost *:80>
ServerName www.example.com
DocumentRoot C:/Web/tcomocom
</VirtualHost>

[edited by: jdMorgan at 5:12 pm (utc) on May 27, 2005]
[edit reason] No URLs or emails, please. See TOS. [/edit]

jdMorgan

5:23 pm on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



tcomo,

Welcome to WebmasterWorld!

> One indication I may have a problem is that if you request http://example.com instead of http://www.example.com, it loads the primary site instead.

This is normal and expected. The server has no knowledge that the www and non-www domains are related in any way - they are two different domains and may in fact be hosted on separate servers (OK, technically www.example.com is a subdomain of example.com, but the statement still applies).

If you wish the server to handle both, then you can use the ServerAlias [httpd.apache.org] directive to declare additional server names. Otherwise -as documented- the server will default to the first <VirtualHost> it finds, which is what you observe.

As far as a one-size-fits-all config file, I doubt that there is such a thing.

Jim