MediaWiki/Short URLs

From DreamHost
Revision as of 13:53, 24 August 2009 by Sherrardm (Talk | contribs)

Jump to: navigation, search

< MediaWiki

Beautifying URLs

See also Short URL in the MediaWiki Manual

If your wiki is installed under a "wiki." subdomain

See also: Short URL like wiki.example.com/Page_title in the MediaWiki Manual
  1. Install MediaWiki in a directory, e.g., ~/wiki.yourdomain.com/
  2. Configure your wiki as normal with ugly URLs
  3. Modify the following options in LocalSettings.php
$wgScriptPath       = "";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";
$wgArticlePath      = "$wgScriptPath/$1";
  1. In the ROOT directory of wiki.yourdomain.com place the following .htaccess file:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(skins|stylesheets|images|config)/
RewriteCond %{REQUEST_URI} !^/(redirect|texvc|index).php
RewriteRule ^(.*)$ /index.php?title=$1 [L,QSA]

It seems, that if you're using mediawiki 1.12.0, then the "Special" links will be broken with this approach. One possible solution is to use the patch from this link: http://blog.gugl.org/archives/27

If your wiki is installed under a "www." subdomain

See this post in the Dreamhost forums. This method is also described here at Mediawiki.org.

This method will produce URLs (for content pages, not edit pages) that look like www.yourdomain.com/wiki/Content_title

  1. Install MediaWiki in www.yourdomain.com/w and not in www.yourdomain.com or www.yourdomain.com/wiki using the Dreamhost control panel
  2. Configure your wiki as normal with ugly URLs
  3. Modify the following options in LocalSettings.php
$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";
  1. In the ROOT directory of www.yourdomain.com place the following .htaccess file:
RewriteEngine on

# uncomment this rule if you want Apache to redirect from www.mysite.com/ to www.mysite.com/wiki/Main_Page
# RewriteRule ^$ /wiki/Main_Page [R]

# do the rewrite
RewriteRule ^wiki/?(.*)$ /w/index.php?title=$1 [L,QSA]

If your wiki is installed in a /wiki/ directory

  1. Install MediaWiki in www.yourdomain.com/wiki using the Dreamhost control panel
  2. Configure your wiki as normal with ugly URLs
  3. Modify the following options in LocalSettings.php
$wgScriptPath = "/wiki";
$wgArticlePath = "$wgScriptPath/$1";
  1. In the ROOT directory of www.yourdomain.com place the following .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wiki/?(.*)$ /wiki/index.php?title=$1 [L,QSA]

Ampersand problems

Using rewrite rules will cause pages with ampersands and possibly question marks in the title to break.

See http://bugzilla.wikimedia.org/show_bug.cgi?id=7424 and http://mail.wikipedia.org/pipermail/mediawiki-l/2005-June/005814.html for further information. This should be updated when somebody figures out if the alias works correctly.