Use VirtualDocumentRoot for htaccess local development in MAMP

Want each of your local development sites to have their own root and be accessible via the browser with whatever name you choose? Okay.

Install MAMP according to this tutorial.

Note that we’ll want to set Apache and MySQL ports to their defaults (80 and 3306, respectively) – as mentioned in the tutorial.

Now! Much of what I’ll include here was taken from this tutorial, but with a few updates:

We need to open this file:


Find the line:

#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

And remove the hash tag (#), so that the line is evaluated and the extra/httpd-vhosts.conf file runs.

Like the above tutorial, we’ll edit the /etc/hosts file and the /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf file as follows:

/etc/hosts:    dev.localhost    clientb.localhost


NameVirtualHost *:80
<VirtualHost *:80>
    ServerName localhost
    ServerAlias *.localhost
    VirtualDocumentRoot /Users/myname/Sites/%0

    RewriteLogLevel 3
    RewriteLog "/Applications/MAMP/logs/rewrite.log"

    <Directory /Users/myname/Sites>
       Options All
       AllowOverride All
       Order allow,deny
       Allow from all

Then – create your Site files within this directory (or any other matching the above configuration):


To match the structure of the /etc/hosts/ file:


Restart the MAMP server and point a browser to http://dev.localhost.

Now you can add .htaccess files to be evaluated on a per “site”.

Happy deving.