web site doesn't respond to www.example.com address

i have a domain, say example.com and I host web site using the Apache web server

my website config file (/etc/apache2/sites-available/example.com) looks as follows:

 <virtualhost example.com:80="">ServerName example.com
    #ServerAlias www.example.com
    DocumentRoot "/var/www/sites/example.com/current/public"
    ErrorLog "/var/log/apache2/example.com-error_log"
    CustomLog "/var/log/apache2/example.com-access_log" common
    <directory "="" var="" www="" sites="" example.com="" current="" public"="">Options All
        AllowOverride All
        Order allow,deny
        Allow from all</directory> 
    RewriteEngine On
    # Remove the www
    RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]</virtualhost> 

The website responds to example.com address but doesn't respond to ****www.****example.com

Am I missing something?

5 Replies

The line that would cause it to respond to www.example.com is commented out…


The line that would cause it to respond to www.example.com is commented out…

Nope, the server doesn't respond to ****www.****example.com regardless www.example.com (ServerAliase) is commented out or it's not commented out.


You might also be missing an A record or CNAME for "www" in your DNS Manager (or wildcard DNS record to catch all subdomains). While I'm a big fan of obfuscating domains in open forums for script/code help, this is one case where having the actual domain would make it a lot easier to figure out the problem.

My settings seemed to be OK, I just had to clean up browser's cache or just hit Ctrl+F5


Please enter an answer

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