Wednesday, August 17, 2016

Use external folder as DocumentRoot in Apache

When adding a new Virtual Host in Apache with DocumentRoot outsite of the default htdocs folder (xamp), you need the red line in your server virtual host configuration:

<VirtualHost *:80>
    ServerAdmin myemail@mydomain.com
    DocumentRoot "C:/xampp/photography"
    ServerName mydomain.com

    ErrorLog "logs/mydomain.com-error.log"
    CustomLog "logs/mydomain.com-access.log" common

<Directory "C:/xampp/photography/">
Options Indexes MultiViews
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>

If not, you gonna get the Do not have permission error when trying to access your website.