Articles/Using mod_rewrite With PHP
After a LOT of trial and error, I’ve come to a few conclusions about using mod_rewrite with PHP:
- If you have a folder /foo/, you can’t have both /foo/index.php and /foo/Rewrite very easily. It makes it much easier if you have /foo/Rewrite and /f/index.php. (Source: Wikimedia)
Here’s the .htaccess for this wiki:
# /wiki/Title as an alias to /wiki/index.php?title=Title
RewriteEngine on
# wiki pages
RewriteRule ^wiki/([^.]*)$ /w/index.php?title=$1 [L,QSA]
# files in the wiki folder (e.g. images)
RewriteRule ^wiki/(.*)$ /w/$1 [L,QSA]