apache httpd.conf - virtualhost configuration
Posted
by
Adam
on Server Fault
See other posts from Server Fault
or by Adam
Published on 2012-12-18T21:44:01Z
Indexed on
2012/12/18
23:04 UTC
Read the original article
Hit count: 300
I'm new to apache and httpd.conf
The problem I'm having is I need different website to go to different vhost configs and if only the IP is requested it needs to go to the root index.html
This works fine for the virtualhosts:
<VirtualHost *:80>
DocumentRoot /var/www/html/bali-accommodation.co
ServerName www.bali-accommodation.co
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/balibeach.co
ServerName www.balibeach.co
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html/dating-website.co
ServerName www.dating-website.co
</VirtualHost>
However when I just specify the IP it does to www.XXX.XXX.XXX.XXX (appends the www).
I know in the websites there is a .htaccess redirect that adds the www but I didn't want the IP to go into the vhosts config.
I tried adding this to the top of the Vhost config:
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName localhost
</VirtualHost>
with above it shows the index.html perfectly but all the websites go into this catch all.
I've also tried this for the websites vhosts:
DocumentRoot /var/www/html/bali-accommodation.co ServerName www.bali-accommodation.co
I've tried the above with and without the 'www' in the first line unsuccessfully.
Is there a way to have the vhosts work for the domains and if someone just enters the IP it goes to the root index.html? /var/www/html/index.html?
thankyou so much Adam
© Server Fault or respective owner