tags:

views:

103

answers:

3

I am going to build a website on a test server that will behave differently depending on which domain is used to access it (The real website will have multiple domains pointing to it).

But how will I be able to simulate the different domains on the test server?

+9  A: 

Just create fake domains pointing to your localhost in /etc/hosts file.

For example,

127.0.0.1   localhost domain1.com domain2.com

On Windows, this file is,

WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
ZZ Coder
Thanks, do you know where the file would be on ubantu/linux? Thanks!
John Isaacks
isn't it /etc/hosts for all unixes?
baloo
to search for the file just type: `find / -name hosts`
RJD22
@baloo: I believe so.
R. Bemrose
+1 I've used this to great effect in the past!
Dean Harding
This works locally, but the only way I can reach it from another machine is if I do http://linux-server. I tried adding domain1.com to the second line 127.0.1.1 but still no luck.
John Isaacks
+2  A: 

try to edit you hosts file http://en.wikipedia.org/wiki/Hosts_file

Claudio
+2  A: 

you will need to edit your hosts file like ZZ Coder is saying. But to point the domain to a certain map you will need to edit the httpd.conf files. I add these kind of redirects in my httpd-vhosts.conf

<VirtualHost *:80>
    ServerName yourfakedomain.com
    DocumentRoot "/var/www/html/"
    <Directory /var/www/html/>
    Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>
RJD22