Manual:Short URL/wiki.example.com/Page title--Subdomain using Lighttpd

From MediaWiki.org

Jump to: navigation, search

[edit] Subdomain with no Subdirectory in Article URL using Lighttpd

Warning: this method may create an unstable URL structure and leave some page names unusable on your wiki. See Manual:Wiki in site root directory.

Please see the article Cool URIs don't change and take a few minutes to devise a stable URL structure for your web site before hopping willy-nilly into rewrites into the URL root.

To put MediaWiki in a root directory with the Lighttpd webserver, use the following rule (assuming mod_rewrite is loaded and your wiki is installed into /w relative to your document-root):

[edit] In LocalSettings.php

$wgScriptPath = '/w';        # Path to the actual files. This should already be there
$wgArticlePath = '/$1';  # Virtual path. This directory MUST be different from the one used in $wgScriptPath
$wgUsePathInfo = false; # To get special links like history or edit work

[edit] In your lighttpd.conf

url.rewrite-once = (
   "(^/[^:]*[\./].*)" => "$1",
   "^/([^?]*)(?:\?(.*))?" => "/w/index.php?title=$1&$2",
)

If you want to host this on a seperate domain (which is very likely for a wiki in the root-dir) do:

$HTTP["host"] == "wiki.example.com" {
   server.document-root = "/path/to/webroot"
   url.rewrite-once = (
       "(^/[^:]*[\./].*)" => "$1",
       "^/([^?]*)(?:\?(.*))?" => "/w/index.php?title=$1&$2",
   )
}

If you want to allow ampersands in titles too (or any other character that might be considered an argument delimiter in the query string) you can make a more complicated rule using mod_magnet. For more information, see lighttpd's documentation about mod_magnet on their website.

Personal tools