clwill00

Q: Allowing .htaccess on your OSX web server

I followed these steps here: Setting up a local web server on OS X, and it was great.  Except I struggled for hours with one small issue and I thought it was useful to note.  Except there's no way to comment on that article?

 

The issue is that if you want to allow .htaccess files (common for Wordpress and many other pieces of software) you have to make two small changes to the instructions (listed here for Yosemite).

 

<Directory "/Users/<your short user name>/Sites/">

    AddLanguage en .en

    LanguagePriority en fr de

    ForceLanguagePriority Fallback

    Options Indexes MultiViews FollowSymLinks

    AllowOverride All

    Order allow,deny

    Allow from localhost

     Require all granted

</Directory>

 

The two changes are to add the Option FollowSymLinks and change AllowOverride to All.

 

Hope this helps someone and saves them the hours it cost me.

Posted on May 7, 2015 11:29 AM

Close

Q: Allowing .htaccess on your OSX web server

  • All replies
  • Helpful answers

  • by water-not-words,

    water-not-words water-not-words Sep 28, 2015 7:10 PM in response to clwill00
    Level 1 (0 points)
    Sep 28, 2015 7:10 PM in response to clwill00

    Following this guide as well as the suggestion above, I managed to get .htaccess rewrite working with difficulty and not ideally.  I am posting the additional steps I've taken as well as posing my question here incase clwill00 can answer for everyone.

     

    Although, the "Sites" directory I created in my home directory works fine with both html or php pages, when I created an .htaccess file in that directory it did not appear to work.  When I troubleshooted the problem (partially using this guide), I found the file was being read.  On a forum I read that some servers require the "RewriteBase /" command, which I added.  Eventually I figured out that on yosemite 10.10, despite having the the .htaccess file in the "Sites" directory as setup up in the apache config files (see first guide) was redirecting to the default /Library/WebServer/Documents directory with the "RewriteBase /" command (and not working at all without it).

     

    Currently, by putting the the files I want to rewrite to in the /Library/WebServer/Documents directory and the .htaccess file in the "Sites" directory I created and referenced in the apache config files as per the first guide, I have gotten rewrites working to a test PHP file, using the following .htaccess file:

     

    RewriteEngine on

    RewriteBase /

    RewriteRule ^.*$ test.php

     

    This is fine for me, since I am only using the server for basic testing purposes, but still I would really like to understand the issue and be able to fix it, and others who are using their MAMP server for small scale hosting, etc, may need this info too.

     

    Any help would be appreciated.

  • by Camelot,

    Camelot Camelot Sep 28, 2015 10:40 PM in response to water-not-words
    Level 8 (47,305 points)
    Mac OS X
    Sep 28, 2015 10:40 PM in response to water-not-words

    I'm not sure what the confusion is.

     

    The apache docs clearly state:

     

    This directive is required when you use a relative path in a substitution in per-directory (htaccess) context