It's the first time that I try to configure apache so I hope you can help me.
This is what I want to achieve:
- All undefined subdomains should lead to not found if they aren't defined
- Root folder should never be accessible
Now this is what I have so far:
my.conf
ServerName server1 (is hostname)
ServerSignature off
ServerTokens prod
Options -Includes
Options -ExecCGI
sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /htdocs
<Directory />
Options None
Order deny,allow
Deny from all
</Directory>
<Directory /htdocs/>
Options -Indexes -FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sites-available/example
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /htdocs/example
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Well, my questions are:
- Does the "Directory /" from the default-config also apply on the example.com site? Or do I need to put it in there, too. Or should it rather be in the my.conf?
- Same question for "Directory /htdocs/" - should I put this in the example.com-config, too? Of course like "Directory /htdocs/example/" then.
- At the moment every subdomain of the example.com is leading to the default directory. How can I prevent that? Only the Server IP should lead there - if at all.