Search code examples
apache.htaccessosx-mavericks

Enable .htaccess file in OS-X Mavericks


I have my website code at /Library/WebServer/Documents/edu and I'm using the following .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]

which I've put under /Library/WebServer/Documents/edu, but apache server seems to be ignoring this file and whatever changes I'm doing here are not taking effect. Do I need to do some additional changes ?


Solution

  • By default Apache has .htaccess disabled, so you would have to enable it.

    Go to and edit /etc/apache2/httpd.conf

    You will find a section that looks like this:

    <Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    </Directory>
    

    You have to change AllowOverride None to AllowOverride All and then find the section right after which should start with: <Directory "/Library/WebServer/Documents"> and you'll have to change the same thing there to AllowOverride All