In a previous post we set up a virtual host on MAMP using a folder located on its apache root folder (/Applications/MAMP/htdocs), but if we already had our website's files in another folder, and we do not want, or can not, move them to the root folder, we can use a symbolic link to make those files available on MAMP.
Let’s say we have our website on the following folder:
/Projects/mysite/
We create the symbolic link with the "ln" command.
cd /Applications/MAMP/htdocs
ln -s /Projects/mysite/ mysite
Then, we add a corresponding virtual host entry on the /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf file.
<VirtualHost *:8888>
DocumentRoot "/Applications/MAMP/htdocs/mysite"
ServerName mysite.localhost
<Directory "/Applications/MAMP/htdocs/mysite">
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
And update the hosts file accordingly.
127.0.0.1 mysite.localhost
After we restart the MAMP server, our site would be available at the http://mysite.localhost:8888 url.
Note: If you hadn't yet enabled the Virtual Host functionality on MAMP, please check the previous post Set up a virtual host on MAMP on Mac OS X to learn how to do it.