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 not sure when, but suddenly subdomains aren't working on my server.

e.g. www.davidlawson.co works, but david.lawson.co isn't working.

<VirtualHost 173.203.109.191:80>
        ServerAdmin david@lawson.co

        ServerName david.lawson.co
        ServerAlias davidlawson.co
        ServerAlias www.davidlawson.co

        DocumentRoot /var/www/lawson/david
        <Directory /var/www/lawson/david/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/lawson/david/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/lawson/david/access.log combined

</VirtualHost>

Any suggestions on how to debug this further, or what the problem might be?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Your Apache server seems to be doing a 301 redirect to www.david.lawson.co which doesn't exist in DNS. Have you added anything to the .htaccess or the site code which would redirect to www.$HOSTNAME?

share|improve this answer
    
RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ %{HTTP_HOST}/$1 [R=301,L] can I change these to allow specific subdomains? –  David Lawson Jan 5 '11 at 11:50
    
You can enter multiple rewrite conditions before the RewriteRule. So for example add: "RewriteCond %{HTTP_HOST} !^david\.lawson\.co$" before the first RewriteCond, and the RewriteRule will only trigger if the host is not dave.lawson.co AND it does not start with www. –  Niall Donegan Jan 5 '11 at 12:02
    
!^(www|david)\. –  David Lawson Jan 5 '11 at 12:03
    
thank you so much! :) wish I could + –  David Lawson Jan 5 '11 at 12:03

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.