Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.
<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias example.com
    DocumentRoot /var/www/example/example

When I open the website on my browser like www.example.com it is listing all the files under /var/www/example directory instead of a page!

But if I use ServerAlias www.example.com it works fine just wondering what could be the problem?

share|improve this question
Please rephrase your question. What exactly doesn't work? What exactly do you expect to happen and what does happen instead? –  joschi Jul 13 '10 at 5:39

1 Answer 1

up vote 1 down vote accepted

When Apache httpd receives a host name in the HTTP/1.1 Host header which no VirtualHost exists for or no Host header at all, it'll serve the first VirtualHost it encounters in its configuration.

www.example.com is currently not configured in your snippet, so Apache httpd will serve the default VirtualHost which probably has the DocumentRoot /var/www/.

If you want to know details you should read An In-Depth Discussion of Virtual Host Matching.

share|improve this answer

Your Answer


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.