Tuesday, April 7, 2009

Apache on OS X Leopard MOD_REWRITE / .htaccess issues (Mysterious 500 Internal Server Error CakePHP Apps + no dir index +403 Forbidden for phpmyadmin)

Ok, so after over a week of brokenness and screwed up Apache Brad and I finally diagnosed a problem i've been having with XAMPP.

Here's what happened / Symptoms:
I was working with wildflower and wanted to try a branch I had downloaded from GitHub. Well, somehow during archive extraction the .htaccess files did not get copied over correctly. So I jumped into the terminal and was (rather carelessly) copying the .htaccess files to their proper places.


I get the files copied over and run a few tests on the demo pages to see if my CSS and images were showing up and everything seemed to be working just fine. Oh no. I inserted some test data using a form within the application and went to jump into phpmyadmin. Well phpmyadmin was telling me that the url /phpmyadmin was forbidden on the server.

All browser requests to http://localhost also stopped working, but I could ping localhost from the terminal, but nothing would work from a browser.

So I started debugging it and got access to phpmyadmin by turning 'AllowOverride' to None in /etc/httpd.conf - but this is no good because I need mod_rewrite to work in my cake applications.

I tried completely destroying my XAMPP installation and reconfiguring it from scratch, still the errors persisted. I was either able to have access to phpmyadmin but no URL rewrite OR I could have URL-rewrite but no access to phpmyadmin. 

The Cause:
As I said before, I had been copying the .htaccess files around. I had accidentally copied .htaccess to the root directory of OS X. I have no freaking clue why, but for SOME reason, Apache on OS X picked up the misplaced cakephp .htaccess file and then attempted to apply the rewrite rules to everything underneath /

I don't know if this applies to other distributions of apache as well, but I figured  I would write a quick blurb about it in case anyone else runs across this issue.

3 comments:

devinhedge said...

I ran smack into the same problem this morning after enabling the rewrite engine (RewriteEnginer On) in an htaccess file nested within the default user profile htdocs (/Users/%username%/Sites/path-to-site/.htaccess). I can't seem to get past it.

devinhedge said...

I came upon this thread: http://ow.ly/2X96

Adding Options +FollowSymlinks to the beginning of my .htaccess file did the trick.

Steve Hatherley said...

@devinhedge Glad you got it working. In my install of Apache, followSymlink is enabled by default in httpd.conf

Post a Comment