Can someone tell me what httpd.conf settings I need to acomplish this?

When in browser I access http://IP I want to show: /var/www/html/ And when I access http://domain I want to show /var/www/html/_domains/domain

But I don't know how the (or whatever option) should look like, the http://IP keeps showing the domains directory rather than the html root.

link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

Use 'NameVirtualHost' on the IP address. Then, for the two individual configurations, use a VirtualHost that precisely matches the IP, and a ServerName specifying the server's name. For the access by IP address, the server name is the IP address.

link|improve this answer
I did a NameVirtualHost IP:port then two VirtualHost; in first the address and ServerName is site.com; and in second, address and ServerName is the IP. It works but I am confused, I was expecting it to work cleaner without specifying exact IP, just by associating a domain to a folder, and all other requests go to document root, without mentioning any IP. Is that possible? – adrianTNT Nov 12 '11 at 1:09
If you do that, and anything is wrong with DNS when Apache starts up, Apache will misconfigure itself. – David Schwartz Nov 12 '11 at 1:14
Sorry, you mean it would be bad not to specify IP? Or all setup I mentioned? – adrianTNT Nov 12 '11 at 1:21
You would be relying on the server to use DNS to find the IP. If that failed for some reason, the server couldn't configure itself. – David Schwartz Nov 12 '11 at 1:24
Thank you for your help. – adrianTNT Nov 12 '11 at 10:47
feedback

If you are using nginx, I would say to have two server blocks, and give the IP-based one an arbitrary name but set the default keyword like so:

listen 80 default;

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.