Reputation: 11
I have two virtual hosts setup, subdomains, in Apache2 on a Debian server. The ip is 104.130.6.104. When the ip is entered in the browser, apache returns the files for blog.goaltilt.com. I want it to return the files for www.goaltilt.com. I’ve searched for an hour for the answer. Can someone help me understand how to force apache to resolve the ip to the my chosen subdomain?
goaltilt.com.conf is:
<VirtualHost *:80>
ServerName goaltilt.com
ServerAlias www.goaltilt.com
ServerAdmin [email protected]
DocumentRoot /var/www/goaltilt.com/public_html
</VirtualHost>
blog.goaltilt.com.conf is:
<VirtualHost *:80>
ServerName blog.goaltilt.com
ServerAdmin [email protected]
DocumentRoot /var/www/blog.goaltilt.com/public_html
</VirtualHost>
Upvotes: 0
Views: 1092
Reputation: 11
I figured out that I had disabled the 000-default.conf file so the server was resolving to the first virtual host in sites-available. I modified the 000-default.conf file to ensure it went to the primary site and then enabled it and restarted apache to get it running. Now the 000-default.conf file resolves the 104.130.6.104 IP to the correct virtual host. Thanks for your help Alvin. Your answer helped me figure out what to look for in the documentation.
Upvotes: 1
Reputation: 7764
Normally a hostname should be mapped using DNS, so based on your comments you are using IP not names. Since that is the case, you'll need to modify your hosts file, or if you happen to be a network admin, you could add a cname
.
On windows you would modify the file C:\Windows\System32\drivers\etc\hosts
and add something like this to the file:
192.168.20.24 blog.goaltilt.com
Then when you enter in your Browser on that Windows machine http://blog.goaltilt.com
, it will send that hostname to your Apache server (above example shows '192.168.20.24' as the server address) and resolve appropriately.
On Linux, you would need to modify the /etc/hosts
files and use the same format.
Upvotes: 0