MediaWiki Apache Conf
The following was posted to MetaWikiPedia:Talk:Rewrite_rules.
brainsik's solution (no mod_rewrite)
Note: The following solution was created for MediaWiki v1.4 but will probably work for v1.3.
In your LocalSettings.php:
$wgScriptPath = "/static"; $wgScript = "/index.php"; $wgRedirectScript = "/redirect.php"; $wgArticlePath = "/$1";
In your Apache config (.htaccess or whatever):
Alias /index.php /var/www/dev.bittorrent.com/mediawiki/index.php Alias /redirect.php /var/www/dev.bittorrent.com/mediawiki/redirect.php Alias /config/ /var/www/dev.bittorrent.com/mediawiki/config/ Alias /static/ /var/www/dev.bittorrent.com/mediawiki/ AliasMatch ^/(robots.txt|favicon.ico)$ /var/www/brainsik/mediawiki/$1 Alias / /var/www/brainsik/mediawiki/index.php/
What's going on?
First off, if you look at LocalSettings.php you'll notice that $wgScriptPath is prepended to all the static content (images, skins, etc). Might as well rename this variable to a fake directory called "/static". This let's us easily match this type of content and has the added bonus that we do not need to specifically match against all the different names static content might be under (which means this will probably continue to work even if new directories are added in the future).
Since we modified $wgScriptPath we have to manually modify $wgArticlePath to be clean.
The hard to understand part is defining $wgScript to be "/index.php" and having our first Alias match this. What's up?? When I first setup my rules I was having the same slow page loading problems as everyone else. It was due to the browser being given URLs like http://yoursite/?title=-&action=raw&gen=js. Those were ending up in a redirect loop and the browser wouldn't show the page content until it had failed out on them. These links aren't actually critical to viewing the page, so most people probably aren't noticing. If you take a look at wikipedia you'll notice they have those kinds of links prepended with '/w/'. Aha! Why not prepend our links, and hey, why not just give them want they want? So, setting $wgScript to "/index.php" creates URLs like http://yoursite/index.php?title=-&action=raw&gen=js which we match for in our first Alias rule and gives the added bonus that we are backwards compatible with old link style. Yay!
-- brainsik