Rewriting feed URLs


· MediaWiki · Wikimedia · RSS · indieweb ·

I've finally got my RSS feeds back up and running. The issue ended up being the fact that I'm running my wikis in the site root directory, i.e. without the /wiki/ in the URL like Wikimedia sites have. I've never liked the redundancy of it, and especially with .wiki domains it looks a bit silly (e.g.…).

I thought for ages that it was because of the precedence of RewriteRules within Directory sections vs those within VirtualHost sections, but that was a red goose chase. It was actually that MediaWiki prioritises the title it finds in PATH_INFO over one supplied in the query string, so /Foo?title=Bar is seen as having a title of Foo instead of Bar.

To fix it, I turned off $wgUsePathInfo, set the $wgArticlePath to include the full domain name (bad, perhaps; this might come back to bite me), and then appended the path info as {{{1}}} in a rewrite rule. So the Apache config looks like this:

<Directory "/var/www/mediawiki">
	RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php?title=$1 [L,QSA]
<VirtualHost *:443>
	DocumentRoot /var/www/mediawiki
	RewriteRule ^/news.rss /index.php?title=Special:CargoExport&table=posts&… [NC,QSA]

And the MediaWiki config like this:

$wgScriptPath = '';
$wgArticlePath = 'https://' . $_SERVER['SERVER_NAME'] . '/$1';
$wgUsePathInfo = false;