0

I'm trying to map daniel.mydomain.tld to /home/daniel/public_html instead of /var/www, while mydomain.tld should still point to /var/www.

So far I have enabled mod vhost_alias using a2enmod vhost_alias.

Furthermore I edited sites-enabled/000-default.conf to

<Virtualhost *:80>
        ServerName mydomain.tld
        ServerAdmin www@localhost
        ServerAlias mydomain.tld
        DocumentRoot "/var/www"
        AccessFileName .htaccess
        <Directory "/var/www">
                Options Indexes FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>
</VirtualHost>

and created sites-enabled/daniel.conf with the following content

<Virtualhost *:80>
        ServerName daniel.mydomain.tld
        ServerAlias daniel.mydomain.tld
        ServerAdmin www@localhost
        DocumentRoot "/home/daniel/public_html"
        AccessFileName .htaccess
        <Directory "/home/daniel/public_html">
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>
</VirtualHost>

Once I was done I restarted the server using service apache2 restart.

When I load up mydomain.tld in my browser I get to the index.php which is located in /var/www, so that works like expected.

Trying to browse mydomain.tld/~daniel/ works just fine, too, showing me the contents of user daniel's /home/daniel/public_html folder.

However, visiting daniel.mydomain.tld brings up 403 Forbidden - You don't have permission to access / on this server.

What am I doing wrong? How do I map daniel.mydomain.tld to /home/daniel/public_html folder?

I'm on Debian 8 (Jessie) running Apache/2.4.10 (Debian).

2
  • 1
    Check if Apache2 user has read permissions on that folder. Also you'd probably want to add "Order Allow, Deny; Allow from all" to your Directory section. Also if you want to show the contents of that folder (not index file) you have to enable Auto Index like you have on your mydomain.tld directive: Options Indexes. – squirrely Mar 10 '16 at 7:49
  • The problem was Option FollowSymLinks, removing that option made it behave exactly the way I need it to. I assume it clashed with the permissions. Thanks for the tips though, I'll probably add Indexes. – phew Mar 10 '16 at 15:59
0

Removing Option FollowSymLinks made it behave exactly like I wanted it to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.