0

I activated the userdir mod with apache2 and configure my domain to get the content of the www folder in my home. I create a Virtualhost for the main domain which works good. But now i would like to automatically add a subdomain for each folder in my /home/user/www/

Here is the virtualhost i code, but it redirect all the subdomains to the /home/user/www/

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mysite.com
ServerAlias *.mysite.com

DocumentRoot /home/user/www/

UseCanonicalName Off
VirtualDocumentRoot /home/user/www/%1

<Directory /home/user/www/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
</Directory>

ErrorLog /var/log/apache2/error.mysite.log
LogLevel warn

CustomLog /var/log/apache2.mysite.log combined
</VirtualHost>`
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Xavier
  • 3,919
  • 3
  • 27
  • 55

1 Answers1

0

Try changing:

VirtualDocumentRoot /home/user/www/%1

to:

VirtualDocumentRoot /home/user/www/%0

You can read more about this feature at mod_vhost_alias.

rr-
  • 14,303
  • 6
  • 45
  • 67