Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create Subdomain

Status
Not open for further replies.

bher20

Technical User
Dec 6, 2006
13
US
Hello all,
I am running Windows Server 2003 as a DNS server and using WAMP for apache.
I am having a lot of trouble tring to get virtual hosts working here is my vhosts file.

"#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.

<VirtualHost *:80>
ServerName blogs.example.com
ServerAlias blogs
DocumentRoot C:/wamp/</VirtualHost>

<VirtualHost *:80>
ServerName example.com
DocumentRoot C:/wamp/</VirtualHost> "

and when ever i go to, for example, "blogs.example.com" it show me the site at example.com
Any help would be great.
 
Is example.com defined in httpd.conf? The reason I ask is because if a particular vhost can't be found, apache will use the first one defined as the default. In this case it seems to be using the second. This is what makes me think in is defined elsewhere. Are you sure that apche is reading your vhosts file? There is usually an "Include" directive in httpd.conf that will point to all your other config files such as /path/to/*.conf.
 
Yes it is defined in httpd.conf file and it is reading the vhost file.
 
Yeah, this doesn't make sense. Add another one before all of them, with like servername default.example.com. You can test locally by adding it to the local hosts file.

Do you have any rewrites or an .htaccess might be redirecting?

Also, setup different access and log files so you can see where the request is going and how it is interpreted.
 
I tryed default.example.com and it didnt work or write any data in the log file either.
But it did for the main example.com.

I am using wordpress mu in the blogs subdomain and it requires some rewrites in the .htaccess file but I commented them out and not only didnt it work it also wrote no data in the log file I just setup for it.
 
So I am still confused. Put some garbage in the VirtualHost entry for blogs, like "alksjfs" and try and restart apache. It should complain about the syntax error.
 
Also when i try to goto blogs.example.com it looks like it is redirecting me back to example.com.
 
Ok now for some reason it is writing data in the access log file it says "ip.ad.dre.ss - - [02/Sep/2008:13:20:59 -0400] "GET / HTTP/1.1" 301 -" I know 301 is a redirect but I checked the .htaccess for both the blogs.example.com and example.com directories and I am not redirecting in either of these. So now I am really confused.
Sorry about the three post in a row...
 
Try getting rid of that serveralias command for blogs.example.com and see what that does. I usually use serveralias to sypport whatever way a user types in my site name.

For example:

ServerName ServerAlias example.com

That way the user gets my site no matter if they type the not.

You simply have the word "blogs" in there, and it's not a proper domain name. If it is trying to find that domain name and it cannot, then it will give out your "default" domain, which is probably example.com....

It's the same deal if you have 5 virtual sites on the same box and they are all at 12.34.567.89

If you just type into a browser you have no way to tell it which site you want, so you just get whichever one is set as the default.
 
just figured it out, something was miss configured in wordpress. I reran the wordpress mu mstall script and it works beautifully now.
Thank you all for your help.
 
Well, good catch on the 301, I kinda knew SOMETHING was redirecting because the it was contrary to the default behaviour of apache.
 
Thanks very much for all your help elgrandeperro.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top