My virtualhost not working for non-www version

Posted by johnlai2004 on Server Fault See other posts from Server Fault or by johnlai2004
Published on 2010-04-17T16:48:06Z Indexed on 2010/04/17 16:53 UTC
Read the original article Hit count: 405

Filed under:
|

I have a development web server (ubuntu + apache) that can be accessed via the url glacialsummit.com. For some reason, http://www.glacialsummit.com serves pages from the /srv/www/glacialsummit.com/ directory, but http://glacialsummit.com serves pages from the /var/www/ directory. Here's what some of my virtualhost config files look like

filename: /etc/apache2/sites-enabled/glacialsummit.com

<VirtualHost 97.107.140.47:80>
     ServerAdmin [email protected]
     ServerName glacialsummit.com
     ServerAlias www.glacialsummit.com
     DocumentRoot /srv/www/glacialsummit.com/public_html/
     ErrorLog /srv/www/glacialsummit.com/logs/error.log
     CustomLog /srv/www/glacialsummit.com/logs/access.log combined
</VirtualHost>
<VirtualHost 97.107.140.47:443>
     ServerAdmin [email protected]
     ServerName glacialsummit.com
     ServerAlias www.glacialsummit.com
     DocumentRoot /srv/www/glacialsummit.com/public_html/
     ErrorLog /srv/www/glacialsummit.com/logs/error.log
     CustomLog /srv/www/glacialsummit.com/logs/access.log combined

        SSLEngine on

        SSLCertificateFile    /etc/ssl/localcerts/www.glacialsummit.com.crt
        SSLCertificateKeyFile /etc/ssl/localcerts/www.glacialsummit.com.key

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch ".*MSIE.*" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0

</VirtualHost>
<VirtualHost 97.107.140.47:80>
     ServerAdmin [email protected]
     ServerName project.glacialsummit.com
     ServerAlias www.project.glacialsummit.com
     DocumentRoot /srv/www/project.glacialsummit.com/public_html/
     ErrorLog /srv/www/project.glacialsummit.com/logs/error.log
     CustomLog /srv/www/project.glacialsummit.com/logs/access.log combined
</VirtualHost>
## i have many other vhosts that work fine in this file

filename /etc/apache2/sites-enabled/000-default

<VirtualHost 97.107.140.47:80>
    ServerAdmin webmaster@localhost

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

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

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

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

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

filename: /etc/apache2/ports.conf

NameVirtualHost 97.107.140.47:80
Listen 80

<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443
</IfModule>

How do I make http://glacialsummit.com serve web pages from /srv/www/glacialsummit.com/public_html just like http://www.glacialsummit.com?

© Server Fault or respective owner

Related posts about apache2

Related posts about virtualhost