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.

I don't have a domain name for my server yet but do for one of my sites that I will host there. If you navigate to the site via the IP address I want you to go to D:\Apache . If you go to the server via mydomain.com or www.mydomain.com I want you to go to D:\Apache\mydomain. How would I do this using apache?

share|improve this question
add comment

2 Answers

You should use name based virtual hosting It defines sites, using Host header defined in HTTP/1.1 spec. Example confing

 NameVirtualHost *:80 
<VirtualHost *:80>
   ServerName www.example.com 
   DocumentRoot D:\example.com
</VirtualHost>
<VirtualHost *:80>
  ServerName example.example.com 
  DocumentRoot D:\example.com\example
</VirtualHost>
share|improve this answer
add comment

The File may look something like this.

NameVirtualHost *:80
<VirtualHost *:80>

       ServerAdmin my@emailaddy.com
       ServerName  whateverdomain.com
       DocumentRoot D:\Apache

</VirtualHost>
<VirtualHost *:80>

       ServerAdmin my@emailaddy.com
       ServerName  www.mydomain.com 

       # Indexes + Directory Root.
       DirectoryIndex index.php (assuming its PHP)
       DocumentRoot D:\Apache\mydomain

</VirtualHost>

Then Restart Apache

apache -w -n "Apache" -k restart

If you have issues with resoving names, then edit your hosts file

C:\WINNT\system32\drivers\etc\hosts
share|improve this answer
add comment

Your Answer

 
discard

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