0

I use apache2 and I want to have something like username.mydomain.fr

www.mydomain.fr --> /var/www/web-en-royans that is works fine username.mydomain.fr --> /home/username/www that does not work

also, www.mydomain.fr/~username --> /home/username/www that is works fine, but I don't care.

I activate user_dir and vhost_alias.

UseCanonicalName Off

<VirtualHost *:80>
    ServerName www.web-en-royans.fr
    DocumentRoot /var/www/web-en-royans
</VirtualHost>
<VirtualHost *:80>
    ServerName *.web-en-royans.fr
    VirtualDocumentRoot /home/%-3/www
    #VirtualDocumentRoot /home/%1/www
</VirtualHost>

    <Directory "/var/www/web-en-royans">
        Options Indexes MultiViews FollowSymLinks
        Order deny,allow
        Allow from all
    </Directory>
    <Directory "/home/*/www">
            Options Indexes MultiViews FollowSymLinks
            Order deny,allow
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.web-en-royans.fr.log
    CustomLog /var/log/apache2/access.web-en-royans.fr.log combined

I want to work with VirtualDocumentRoot more than rewrite_url Moreover, username.mydomain.fr go to www.mydomain.fr, and whatever.mydomain.fr go to www.mydomain.fr.

I do not even known how to debug or trace it.

psic
  • 349
  • 2
  • 5
  • 17

1 Answers1

0

Very simple, just disable the mod-userdir, and add a ServerAlias

<VirtualHost *:80>
    ServerName www.web-en-royans.fr
    DocumentRoot /var/www/web-en-royans
</VirtualHost>
<VirtualHost *:80>
    ServerName *.web-en-royans.fr
    ServerAlias *.web-en-royans.fr
    VirtualDocumentRoot /home/%1/www
</VirtualHost>
psic
  • 349
  • 2
  • 5
  • 17