0

I have a subdomain:

my.mydomain.com

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
    </Directory>

</VirtualHost>

Question:

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?

2 Answers 2

1

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.

1
  • This is perfect reading for my learning process -- thank you!
    – user48886
    Jul 21, 2010 at 15:10
1

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.

0

You must log in to answer this question.