Using your Mac for development of web applications or websites, is very easy as it already comes with Apache pre-installed, the problem is that .htaccess file does not work by default.
But it is easy to enable it.
First some changes in the main configuration file of Apache.
sudo vim /etc/apache2/httpd.conf
The first thing I will do is to change the Document root from the default /Library/WebServer/Documents to my Sites folder under my home directory.
So, look for these lines:
And change them to:
Of course instead of your-username insert there your real username.
I prefer to have it there, as I do not need root permissions to add content to that folder.
Enable .htaccess file in Mac OS X
In the same file, under the section
<Directory "/Users/your-username/Sites"> look for:
And change it to:
Also edit this file:
sudo vim /etc/apache2/users/your-username.conf
And look for the same line AllowOverride None** and change it to *AllowOverride All
Then restart apache:
sudo apachectl restart
You are now ready to put files to ~/Sites/ folder and when you go to: http://localhost/ you will see those files appear, and if you add a .htaccess file, that is going to work.
If you enjoyed the article, please share it