I'm using the built-in Apache on my Mac OS X (Snow Leopard) to do local testing of my websites. Currently I'm trying to create clean URLs for my PHP website, but I just can't seem to get it working.
Here's my .htaccess:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^gallery/page/([A-Z0-9._%+-]+) gallery/index.php?page=$1 [NC]
I'd like to have it so that http://localhost/gallery/page/TITLE will automatically bring me to http://localhost/gallery/index.php?page=TITLE
My http://localhost/ points to the local folder /Users/voltm/Sites/localhost/ and the website I'm working on is in http://localhost/gallery/ -- local folder /Users/voltm/Sites/localhost/gallery/
When I enter, for example, http://localhost/gallery/page/music in my browser, I get a 404 error The requested URL /gallery/page/music was not found on this server.
I looked into the error log file and it says:
[Thu Apr 05 23:55:39 2012] [error] [client 127.0.0.1] File does not exist: /Users/voltm/Sites/localhost/gallery/page
I've checked on phpinfo() and httpd.conf to see that mod_rewrite is loaded. I've gone into httpd.conf and the conf file in the user folder to make the settings:
Options Indexes MultiViews FollowSymLinks
AllowOverride All AuthConfig
Order allow,deny
Allow from all
And I've restarted Apache several times too.
What am I missing?
EDIT: Fixed! I had to remove the .htaccess file I had lying around in a subfolder.
Finally figured it out! After hours of frustration - installed MAMP, fiddled with the conf files and looked at error logs - I finally came across the comment at the bottom of this page which said I shouldn't have .htaccess files "above and outside of MAMP's webroot directory". I had another .htaccess file in the gallery/ folder and I deleted it-- everything's working fine now.