Monday, August 07, 2006

Virtual hosts in Apache

Getting apache to host two different domains on the same server, but redirecting them to different sites.

In httpd.conf... APACHE_HOME/conf/httpd.conf



Uncomment:
LoadModule vhost_alias_module modules/mod_vhost_alias.so


Then add this to the vhosts section.

NameVirtualHost *

<virtualhost>
DocumentRoot "C:/website1"
ServerName mywebsite1.com
ErrorLog "C:/website1/error.log"
</virtualhost>


<virtualhost>
DocumentRoot "C:/website2"
ServerName mywebsite2.com
ErrorLog "C:/website2/error.log"
</virtualhost>


and for redirecting...

<virtualhost>
DocumentRoot "C:/website3"
ServerName someothersite.mywebsite1.com
ErrorLog "C:/website3/error.log"
Redirect permanent / http://othersite.com:8080
</virtualhost>





No comments:

Post a Comment