Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Ok, I have added lines like:

127.0.0.1   somedomain.com

Or some other domain that points to my routers IP, and is forwarded, but I get to the main site, but I want it to go to the subfolder I defined in my httpd-vhosts.conf:

NameVirtualHost  somedomain.com:80

<VirtualHost somedomain.com:80>
 DocumentRoot "D:/Apps/xampp/htdocs/somedomain"
 ServerName somedomain.com
 ServerAlias somedomain.com
</VirtualHost>

So, locally somedomain.com works, just remotely it goes to the root htdocs. So If I use a *:80 wildcard I works, but then everything points to the subfolder and all the other vhosts seem to get ignored.

Any Idea why this is?

share|improve this question

1 Answer 1

  1. DO NOT, ever, use hostnames in a VirtualHost definition. Use IP:80 or *:80.
  2. Domains are not "forwarded" - traffic is. What you put in your local hosts file has nothing to do with how remote traffic gets routed to your web server.

As always, the ServerName is decisive; the Host: header is compared with the ServerName, and if a matching vhost is found, that is who receives the request.

share|improve this answer
    
1. But then what IP do i put after NameVirtualHost? Just 127.0.0.1? –  TrySpace Apr 12 '12 at 15:14
    
2. So like I have it now it is OK? behind the ServerName? –  TrySpace Apr 12 '12 at 15:15
    
You have that name resolving to localhost, so it's only attached to localhost traffic (why are you using the hosts file, by the way?). Change your vhost directives: NameVirtualHost *:80 and <VirtualHost *:80>. –  Shane Madden Apr 12 '12 at 15:31
    
Thing is, i want bla.bla.com to go to my root (it points to my modem/router), so I have it pointed to /htdocs, and the other, somedomain.com (also pointing to my router IP) I want to point to /somedomain.... –  TrySpace Apr 13 '12 at 15:32
    
How is that related to how vhosts should be set up ? –  adaptr Apr 13 '12 at 15:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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