Apache on a mac redirects to wrong localhost

When I’m testing local applications in apache and I forget to add a slash, Apache redirects to http://petrik.local instead of http://localhost.

This can be fixed by adding the following to your Apache configation in /etc/httpd/users/<YOUR_USERNAME>.conf:

ServerName localhost

admin