How to Fix XAMPP 403 (Forbidden) Error Mac

Sometimes after setting up Virtual Hosts on a fresh installation of XAMPP you might start hitting 403 errors on all your local development sites.

To fix these errors you need to make a couple of tweaks to the httpd.conf file on your XAMPP installation.
This file is normally found under /Applications/XAMPP/xamppfiles/etc/extra.

1. Change the default username to your username

Find your username and group by opening up a terminal and typing users for the username, then groups for the group or id for a more verbose output including user IDs.

Change the username in httpd.conf to

User Username
Group staff

2. Add a new directory block with the correct access rules for your user

You should be able to find this not far down the document.

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

<Directory /path/to/your/sites/folder/ >
    AllowOverride All
    Require all granted
</Directory>

Or just add the permissions per virtual host.

This could be a more secure approach.

<VirtualHost *:80>
    ServerName mysite
    ServerAlias mysite
    DocumentRoot "/path/to/your/site/"
        <Directory /path/to/your/site/ >
            Require all granted
        </Directory>
</VirtualHost>