2

I am setting up a small website in-place on the production server. While we are finalizing all the settings for the final domain we've located it on dev.domain.com, so that our visitors don't see a potentially buggy site as they go to www.domain.com or domain.com. I did this by specifying a virtualhost catching dev.domain.com with the documentroot of the "real" site, and creating a new site with the virtualhost catching www.domain.com and domain.com, with the documentroot pointing to a directory parallell to the "real" site, containing nothing but a index.html. This site would show the visitor a message about the site reconstruction.

These are the site config files:

# dev.domain.com
<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName dev.domain.com

        DirectoryIndex index.html
        DocumentRoot /var/www/www.domain.com/htdocs/

        ScriptAlias /cgi-bin/ /var/www/www.domain.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>

        ErrorLog /var/log/apache2/www.domain.com/error.log
        CustomLog /var/log/apache2/www.domain.com/access.log combined
</VirtualHost>


# a-notice-site
<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName www.domain.com
        ServerAlias domain.com    

        DirectoryIndex index.html
        DocumentRoot /var/www/notice-site/htdocs/

        ScriptAlias /cgi-bin/ /var/www/www.domain.com/cgi-bin/
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>

        ErrorLog /var/log/apache2/www.domain.com/error.log
        CustomLog /var/log/apache2/www.domain.com/access.log combined
</VirtualHost>

So, my problem is this: When typing www.domain.com, www.domain.com. and even domain.com., i reach the notice site just fine, but when accessing just domain.com (without the trailing dot) my browser address bar tells me i've been routed to www.domain.com/notice-site/htdocs and i get a 404 that the url was not found. Accessing the dev site works perfectly.

I have a small hunch that this has something to do with the way i've set up the virtual hosts, but sadly i can't figure out why it would cause this effect. Has anyone heard of something similar or what could cause it?

apache2ctl -S gives:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server www.domain.com (/etc/apache2/sites-enabled/a-notice-site:4)
         port 80 namevhost www.domain.com (/etc/apache2/sites-enabled/a-notice-site:4)
         port 80 namevhost dev.domain.com (/etc/apache2/sites-enabled/dev.domain.com:4)
Syntax OK
3
  • These configs look like they should work, are you fighting some sort of browser issue? Maybe the browser you are using is automatically putting the www in front of domain.com? Can you clear your browser caches and try it again? Make sure you are not pressing [Ctrl]+[Enter] or anything like that.
    – nabrond
    Aug 8, 2012 at 19:43
  • Yep, clearing the caches fixed it. Never occured to me that it could be a client-side problem, cheers
    – Karlinde
    Aug 8, 2012 at 20:22
  • may i ask you to add an answer and accept it so that this question does not appear as unanwered?
    – user130370
    Aug 12, 2012 at 15:24

1 Answer 1

0

These configs look like they should work, are you fighting some sort of browser issue? Maybe the browser you are using is automatically putting the www in front of domain.com? Can you clear your browser caches and try it again? Make sure you are not pressing [Ctrl]+[Enter] or anything like that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .