a night of mod_rewrite
i spent the majority of my night (hours, literally) trying to get urls in my editplus wiki that had looked like this:
http://www.editplus.info/index.php/Main_Page
to look like this:
http://www.editplus.info/Main_Page
which required digging into apache’s complex mod_rewrite module and plodding through some really crappy documentation on setting up the rewrite rules to work with mediawiki.
i think i got it working right, but took some doing. then i thought i’d try to improve the mediawiki documentation, but i started having trouble getting the rewrite rules to work in an .htaccess file (i had done everything in httpd.conf), so i just gave up.
update:
here are my mod_rewrite rules for a mediawiki wiki, which are inside a VirtualHost container in Apache’s httpd.conf file:
# Allow rewriting URLs
RewriteEngine on
#RewriteLog /home/jwatt/rewrite.log
#RewriteLogLevel 4
# fix for URLs like this: hostname.tld/?title=page_title
# if the requested page is the root page "/"
# and the query string contains the title
# return the index page, query string will be automatically appended
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^title=
RewriteRule ^.*$ /index.php [L,QSA]
# Don't rewrite requests for files in MediaWiki subdirectories,
# MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt
RewriteCond %{REQUEST_URI} !/(stylesheets|images|skins)/
RewriteCond %{REQUEST_URI} !/(redirect|texvc|index).php
RewriteCond %{REQUEST_URI} !/error/(40(1|3|4)|500).html
RewriteCond %{REQUEST_URI} !/favicon.icoRewriteCond %{REQUEST_URI} !/robots.txt
# Rewrite http://wiki.domain.tld/article properly, this is the main rule
RewriteRule ^/(.*) /index.php/$1 [L,QSA]
for the last month, it’s worked for me flawlessly.


mod_rewrite is magic.