dannyman.toldme.com


Mac OS X, Technical, WordPress

Mac OS X and per-user Support for .htaccess

Problem

I just spent a fair amount of time wrestling with Apache on my Macintosh. The problem is that it simply refused to read the .htaccess file in my user directory.

My First Approach

I took the “Unix Guy” approach and edited /etc/httpd/httpd.conf to ensure that Apache was configured to consult my user’s .htaccess file. I changed this bit:

<Directory /Users/*/Sites>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes FollowSymLinks IncludesNoExec
    [ . . . ]

To read:

<Directory /Users/*/Sites>
    # AllowOverride FileInfo AuthConfig Limit
    AllowOverride All
    Options MultiViews Indexes FollowSymLinks IncludesNoExec
    [ . . . ]

But . . . nada.

Why That Didn’t Work

Eventually, I found the answer in an O’Reilly Tutorial. Under the section “User-Based Configurations” Kevin Hemenway explains how “per-user” configurations are done in the world of Macintosh:

mini-toldme-com:~/Sites djh$ ls /etc/httpd/users/
djh.conf
mini-toldme-com:~/Sites djh$ cat /etc/httpd/users/djh.conf 
<Directory "/Users/djh/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

The O’Reilly article explains that you could edit that file, sure, but then on the next page, it suggests that .htaccess may be a bit more convenient:

As you’ve run through these various tweaks and twiddles of the Apache configuration file, one thing has always remained true: to make the changes active, you’ve had to stop and start Apache after each edit. Not only is this tedious and subject to forgetfulness, it’s also avoidable with a little thing called an .htaccess file.

He then goes on to explain the AllowOverride thing, but doesn’t point out that /etc/httpd/users is going to spank you. Hopefully, his readers paid enough attention and know that within their ~/Sites directory they’ll have to edit /etc/httpd/users/`whoami`.conf . . .

How I Fixed It

I considered changing my /etc/httpd/users/djh.conf but I suspected that some day whatever created it might create it anew, clobbering my changes, and I would forget it had ever existed, and I would go through this frustration all over again. Since I had already made the appropriate change in my /etc/httpd/httpd.conf and since I am the only user on the system, I simply made one more edit to /etc/httpd/httpd.conf. Down near the end, I changed this line:

Include /private/etc/httpd/users/*.conf

To this:

# What the f_ck g_d d_mned insanity!?
# Include /private/etc/httpd/users/*.conf

Restart Apache and now I can use .htaccess as much as I please.

Read More

Next:
Previous:
Categories: Mac OS X, Technical, WordPress

Discover more from dannyman.toldme.com

Subscribe now to keep reading and get access to the full archive.

Continue reading