edit this page - page history - about editing

Articles/Using mod_rewrite With PHP

Articles

After a LOT of trial and error, I've come to a few conclusions about using mod_rewrite with PHP:
  1. 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]

Categories: Article | Apache | PHP
edit this page - what links to here? - page history - top
Last edited by jevon jevon 60 months ago