Hi,
I have been using apache rewriting in my .htaccess file in order to use
pretty URLs, e.g.
www.mydomain.com/wiki/Page
Here is the code I was using:
RewriteEngine on
RewriteRule
^[^:]*\.(php|src|jpg|jpeg|png|gif|bmp|css|js|inc|phtml|pl|ico|html|shtml)$ -
[L,NC]
RewriteRule ^index.php?title - [L]
RewriteRule ^(.*)$ index.php?title=$1 [L,QSA]
Due to the way mod_rewrite works, pages with Ampersands in them were being
truncated, so if I tried to acces the page "Terms & Conditions" then I
would
actually be directed to the page "Terms".
I found a fix for this on
MW.org, which was to add a rule to rewrite &
symbols with %26, so they were escaped again. My .htaccess file now looks
like this (the fourth line has been added):
RewriteEngine on
RewriteRule
^[^:]*\.(php|src|jpg|jpeg|png|gif|bmp|css|js|inc|phtml|pl|ico|html|shtml)$ -
[L,NC]
RewriteRule ^index.php?title - [L]
RewriteRule ^(.*)\&(.*)$ $1\%26$2
RewriteRule ^(.*)$ index.php?title=$1 [L,QSA]
This successfully solves the above problem. However if I try to go to a
sub-page of a page with an ampersand then the sub-page part of the page name
is doubled. E.g.
T&C/page1 becomes T&C/page1/page1
T&C/page1/page2 becomes T&C/page1/page2/page1/page2
This only applies to pages with ampersands - not to other pages. I have
checked the value of $_GET at the top of index.php and the title parameter
already includes the doubled text, so it is clearly a problem with the
rewrite rule. However I can't figure out what the problem is.
Has anyone else experienced this problem? I am asking here before taking it
to the Apache forums as I suspect it is something that other MediaWiki users
will have encountered and perhaps a fix is already known.
I am using Apache 1.3.37 and MW 1.6.10
- Mark Clements (HappyDog)