Operating System - Linux
1760039 Members
2693 Online
108889 Solutions
New Discussion юеВ

Re: Domain name based location in server

 
SOLVED
Go to solution
Vernon Brown_3
Advisor

Domain name based location in server

I have two domain names pointing to the same IP address. I'm running Apache server that comes with RedHat 7.1. Does someone know if there is a way to direct one domain name to one web page on Apache and direct the other domain name to another web page.
3 REPLIES 3
Jean-Pierre Denis
Valued Contributor
Solution

Re: Domain name based location in server

Hi,

you could use mod_vhosts_alias and add this to your /etc/httpd/conf/Vhosts.conf file

# Dynamic mass virtual hosting

UseCanonicalName Off
VirtualDocumentRoot /var/www/html/vhosts/%2+/%1/
LogFormat "%v %h %l %u %t \"%r\" %s %T %b" VLOG
IndexOptions FancyIndexing IconHeight IconWidth IconsAreLinks FoldersFirst
CustomLog logs/access_log VLOG


This will take the domain name in the header and redirect it to the proper folder.

Exemple:

http://www.domain.com would be redirected to /var/www/html/vhosts/domain.com/www/

--
http://www.domain2.org would be redirected to /var/www/html/vhosts/domain2.org/www/



Thanks,
JP
Open your Mind and use Open Source software...
Vernon Brown_3
Advisor

Re: Domain name based location in server

Thanks, I'll try that. I'll have to study that awhile to understand how it can work.

I take it that the should be the IP address of my server. I don't understand exactly the path. Do I need to create directories under the specific name "vhosts" or is will any path to a folder work??
Jean-Pierre Denis
Valued Contributor

Re: Domain name based location in server

Hi,

Every host using the dynamic mass virtual hosting have a dns "A" record pointing to 192.168.10. My webserver ip is 192.168.1.5 and i've created a virutal interface eth0:0 with the ip 192.168.1.10

The path to the VirtualDocumentRoot could be anything. VirtualDocumentRoot /var/www/html/vhosts/%2+/%1/ . By default Mandrake create the apache root directory in /var/www/html so i created a folder "vhosts" to put all my virutal host. You could change it to what you want. ( /home/httpd/vhosts/... ) and create a folder with the domainname.com and in this directory create the www folder.

The important part is %2+ and %1. This is making the whole thing dynamic.

Host examples and where they would be redirected:

www.domain.com /path/to/vhosts/domain.com/www/index.html
support.domain.org /path/to/vhosts/domain.org/support/index.html
secure.domain.net /path/to/vhosts/domain.net/secure/index.html

Here is some good documentation about virtual hosting:
http://httpd.apache.org/docs/vhosts/mass.html
http://httpd.apache.org/docs/mod/mod_vhost_alias.html


Thanks,
JP
Open your Mind and use Open Source software...