MAMP PRO supports the easy setup of custom domains like awesomeproject.local for developing your web projects. Since I like to stick to learning technologies I found a way to enable the same behaviour in the free version of MAMP.
Basically you need to edit three files to use the virtual hosts with the free version of MAMP, to be able to use domains like: project_name.test in your address bar and without MAMP PRO.
First, enable loading the vhosts config file placed in /Applications/MAMP/conf/apache/extra/.
to the file /Applications/MAMP/conf/apache/httpd.conf
Now you’re ready to edit the httpd-vhosts.conf file and add the hosts for the projects you want to work on.
However, you should remember to put the following at the bottom of the file, so you still can access all your projects by simply going to http://localhost/
This line needs to be at the bottom of your file at all times, even when you add more virtual hosts to this config.
Lastly, make sure you have administrator priviledges to edit the hosts file located in /etc/hosts and add:
or if you want to use IPv6
For completeness sake I have to say, that usually developers use suffixes like .local, .loc or .dev for accessing projects locally, so that’s all up to your imagination what you write after the dot. Just make sure to make it the same in every file for this custom, but local top level domain. I’ve just chosen .devl because it’s up for interpretation if it’s for devil or developer 😉 and with programming, often the devil is in the detail.
Through a comment I’m thankful for, I realised that I should probably supply a use case for this.
For example when you define the RewriteBase in your .htaccess file, this technique can become very handy, since you don’t have to keep one version of it for your remote host and one locally, but can in both cases use something like this:
RewriteEngine On RewriteBase / # more stuff