apache vhost 'www'

Hello everyone!

I was setting up my apache server following the Setting up a LAMP Server on Debian 5.0 (Lenny) but I'm having a problem with my virtualhost. When I type my url with 'www' it works OK, but when I type it without 'www' the default vhost kicks in..

 <virtualhost *:80="">ServerAdmin admin@domain.com
        ServerName www.domain.com
        ServerAlias domain.com
        DocumentRoot /srv/www/www.domain.com/public_html/
        ScriptAlias /cgi-bin/ /srv/www/www.domain.com/cgi-bin/
        <location cgi-bin="">Options +ExecCGI</location> 
        ErrorLog /srv/www/www.domain.com/logs/error.log
        CustomLog /srv/www/www.domain.com/logs/access.log combined</virtualhost> 

Anyone knows why? :\

7 Replies

Try reversing the two.

ServerName domain.com
ServerAlias www.domain.com

@mwaterous:

Try reversing the two.

ServerName domain.com
ServerAlias www.domain.com

I've tried that but the problem persist.. :\

What does your default vhost configuration look like?

Did you restart / reload Apache?

@mwaterous:

What does your default vhost configuration look like?

 <virtualhost *:80="">ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
        <directory>Options FollowSymLinks
                AllowOverride None</directory> 
        <directory var="" www="">Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                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></virtualhost> 

@kangaby:

Did you restart / reload Apache?

yes, I reloaded and restarted the apache but still the same..

Except in reverse. For me, domainname.com does not work but www.domainname.com works. Can someone please shed some light on this? I used the LAMP setup guide as well.

@chimichangaman:

For me, domainname.com does not work but www.domainname.com works. Can someone please shed some light on this?
Do you have A records for both domainname.com and www.domainname.com pointing to the ip address of the webserver?

Travis

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct