Tim Pritlove wrote:
On 29.06.2005, at 19:35, Brion Vibber wrote:
Tim Pritlove wrote:
Pages that contain an Ampersand no longer show
up. Whenever I click on
a link to that page, it strips the page title beginning from the
Ampersand resulting in an unknown page name.
Are you using Apache rewrite rules? Are they different? What are they,
exactly?
i use rewriting. The rules are:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
RewriteRule ^/wiki/?(.*)$ /mediawiki/index.php?title= $1
[L]
</IfModule>
Apache's mod_rewrite un-escapes various hex-encoded characters which
have special meaning in URLs, most insidiously the question mark (?) and
ampersand (&).
The result of this is that an incoming URL like:
/wiki/AT%26T
gets rewritten to:
/mediawiki/index.php?title=AT&T
whose query string gets parsed into this list:
title => 'AT'
T => ''
There's an easy workaround, and a more complete fix. The easy workaround
is (at least if you're using PHP as an Apache module) to switch to using
the PATH_INFO-style URLs:
RewriteRule ^/wiki/?(.*)$ /mediawiki/index.php/$1 [QSA,L]
The '&' character has no special meaning in the _path_ part of the URL
so the rewritten form works:
/mediawiki/index.php/AT&T
However now you'll find that titles with question marks fail similarly,
because the question mark separates the path from the query string:
/wiki/Got_Milk%3F_(advertising_slogan)
/mediawiki/index.php/Got_Milk?_(advertising_slogan)
On our own servers we use a patched version of Apache which adds a
rewrite processing function to specifically re-escape the ampersand into
%26. You'll find a patch for Apache 1.3.x in the MediaWiki distribution
as maintenance/apache-ampersand.diff
Use is something like:
RewriteMap ampescape int:ampescape
RewriteRule ^/wiki/(.*)$ /w/index.php?title=${ampescape:$1} [QSA,L]
Alternatively, you might try replacing the rewrite rule with an alias to
index.php:
Alias /wiki /var/www/mediawiki/index.php
or other such tricks to use the built-in PATH_INFO usage.
-- brion vibber (brion @
pobox.com)