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.

I have a subdomain:


my .conf file looks like:

<VirtualHost *:80>
    ServerName my.mydomain.com
    DocumentRoot /var/www/html/my/

    <Directory /var/www/html/my/ >
        Options FollowSymLinks
        AllowOverride All



If I go to h**p://my.mydomain.com/myfile.txt I see the file. That's good.

If I go to h**p://mydomain.com/my/myfile.txt I see the file as well.

How can I prevent the 2nd option from not seeing the file, while allowing the 1st option to see it?

share|improve this question

2 Answers 2

Create a default <VirtualHost> which catches any hostname which hasn't been set up explicitly.

See An In-Depth Discussion of Virtual Host Matching for details.

share|improve this answer
This is perfect reading for my learning process -- thank you! –  user48886 Jul 21 '10 at 15:10

Unless you want the /my/ to be available under the parent domain, you need to give your subdomain VirtualHost a completely separate DocumentRoot. I take it that /var/www/html/ is the DocumentRoot for the parent VirtualHost? If so, try using something like /var/www/my/ as the subdomain DocumentRoot.

share|improve this answer
And this perfectly solved my issue! Thanks... –  user48886 Jul 21 '10 at 15:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.