PDA

View Full Version : Httpd.conf for V Hosts


SNA
Sun 3rd Jun '01, 2:03pm
Why does this work with the forums but not with other virtual hosts?


This works:

<VirtualHost xx.xx.xxx.xxx:80>
ServerName forums.mysite.com
DocumentRoot /pathtoforums/messageboard
ErrorDocument 404 /notfound.php
</VirtualHost>

This doesnt:


<VirtualHost xx.xx.xxx.xxx:80>
ServerName www.mysite.com
DocumentRoot /pathtoforums/test
ErrorDocument 404 /notfound.php
</VirtualHost>

The only way to get it to work was to do this...

<VirtualHost xx.xx.xxx.xxx:80>
ServerName www.mysite.com
DocumentRoot /pathtoforums/test
ErrorDocument 404 http://www.mysite.com/notfound.php
</VirtualHost>


Now the $REQUEST_URI doesnt work... it just shows /notfound.php not the page I was orginally trying to access.... any ideas?




Why does the forums one work but not the other one?

Thanks,

BobHope
Mon 4th Jun '01, 2:22pm
Replace
ServerName www.mysite.com

with
ServerName mysite.com
- apache doesn't like the www as the main server name.

You also need in there under the above:
ServerAlias www.mysite.com

For the 404 add:
ErrorDocument 404 /notfound.php

Prezident
Tue 12th Jun '01, 6:04pm
The following worked great for me.

First vhost:


<VirtualHost *>
ServerAdmin webmaster@domain.com
DocumentRoot /path/to/www/doc/root/
ServerName www.domain.com
ErrorLog logs/www_error.log
CustomLog logs/www_custom.log common
</VirtualHost>

Additional vhost


<VirtualHost *>
ServerAdmin webmaster@domain.com
DocumentRoot /path/to/www2/doc/root/
ServerName www2.domain.com
ErrorLog logs/www2_error.log
CustomLog logs/www2_custom.log common
</VirtualHost>

Example when running Apache on Windows:


<VirtualHost *>
ServerAdmin webmaster@domain.com
DocumentRoot "D:/path/to/doc/root/"
ServerName www.domain.com
ErrorLog logs/www_error.log
CustomLog logs/www_custom.log common
</VirtualHost>

That's what worked for me, hope that it helps you too.