I'm posting here, because I want to configure apache vhosts automatically, like a.mydomain.com , b.mydomain.com ,etc ... but It doesn't work.
I've already setting up a DNS Wilcard record like ( * 3600 IN A 1.2.3.4 ).
and setting up my appache like this :
<VirtualHost *:80>
ServerName mydomain.com
ServerAdmin [email protected]
ServerAlias *.mydomain.com
DocumentRoot /var/www
DirectoryIndex index.html index.php
VirtualDocumentRoot /var/www/vhosts/%1
UseCanonicalName Off
<Directory /var/www/vhosts>
DirectoryIndex index.html index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Custom Errors
ErrorDocument 404 /errors/404/index.html
RewriteEngine on
RewriteCond /var/www/vhosts/%1 -d
RewriteRule ^(.*) /%1/$1 [L]
RewriteCond %{SERVER_NAME} =*.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =mydomain.com
This is working :
When I'm typing mydomain.com/index.html , I show the good content .
This doesn't work :
When I'm typing a.mydomain.com or something.mydomain.com , I show the same content but normally, It will must show other content . And if I don't type /index.html, I got " Forbidden" .
Can you help me ?