How to configure Apache2 to accept automatic subdomains?
<virtualhost *:80="">ServerAdmin my@email.com
ServerName *.mydomain.com
DocumentRoot /home/xx/mydomain.com/.sub
<directory>Options Indexes SymLinksIfOwnerMatch
AllowOverride All
Order allow,deny
Allow from all</directory>
ErrorLog /home/xx/logs/error.log
CustomLog /home/xx/logs/access.log combined</virtualhost>
When I visit whatever.mydomain.com, it still gives me this error:
Forbidden
You don't have permission to access / on this server.
What am I doing wrong? Thanks!
2 Replies
It doesn't seem like ServerName supports the use of wildcards. ServerAlias does, though.
Second, make sure your home directory (as well as subdirectories and files in the tree in it) is readable by the user and group Apache runs as (it's usually www-data or apache for both the user and the group).
@NeonNero:
As far as I can gather, if you're going to use wildcard hostnames (*.example.com), you must specify one of them in ServerName, and then use the wildcard in ServerAlias.
It doesn't seem like ServerName supports the use of wildcards. ServerAlias does, though.
Second, make sure your home directory (as well as subdirectories and files in the tree in it) is readable by the user and group Apache runs as (it's usually www-data or apache for both the user and the group).
Thanks a lot, Neon. That does the trick.