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'm a complete linux and server noob but I've started a project in an attempt to learn. What I'm trying to do right now is get wildcard subdomains to work.

In my vhost (sites-available) file I have:

<VirtualHost *.80>
ServerName domain.com
ServerAlias www.domain.com domain.com *.domain.com

etc..

In my domain registrar DNS settings I have an A record for @, www and * pointing to my server IP. Now to my knowledge this should be working, however when I go in my browser and browse to *.domain.com it comes up with the default apache text "It works!", when I go to straight to domain.com I can see my web page (which I want to be displaying for *.domain.com too).

Any help would be greatly appreciated! I'm probably missing something blindingly obvious but I'm a noob :)

share|improve this question
    
Damn, it was because I forgot to restart apache after changing the settings, I told you I was a noob :) My first config works. –  zuk1 Jun 24 '09 at 11:00
add comment

3 Answers

i never know about writing ServerAlias option like this

ServerAlias www.domain.com domain.com *.domain.com

if you did well for dns config, try to create vhost config for the real domain (default domain), then create another vhost config for the wildcard after all real domain vhost config.

<VirtualHost *:80>
DocumentRoot "/var/www/html/abc"
ServerName www.abc.com
ServerAlias www.abc.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/var/www/html/abc"
ServerAlias *.abc.com
</VirtualHost>
share|improve this answer
    
as long as you put NameVirtualHost *:80 first i think –  Maxwell Jun 24 '09 at 12:35
add comment

Try this

NameVirtualHost *:80 # enable name virtualhosting
<VirtualHost *:80>  # :80, not .80
   ServerName domain.com
   ServerAlias *.domain.com # www.domain.com matches *.domain.com
   ...
</VirtualHost>
share|improve this answer
    
Apache comments are started with '#' characters not "//". So don't put the "//"s in your config. Replace them with '#'s. –  Jason Tan Jun 24 '09 at 11:22
    
Good point, I'll update my answer –  Dave Cheney Jun 24 '09 at 13:33
add comment
up vote -1 down vote accepted

Nevermind, I forgot to restart apache.

share|improve this answer
add comment

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.