Manual:Short URL/wiki/Page title -- Lighttpd rewrite--root access
From MediaWiki.org
[edit] Lighttpd rewrite #1
Example configuration:
- wiki is installed in /w/ directory in http root dir.
- you want to avoid index.php
- you want to access articles as /wiki/Article
Then there are two things needed to change in two files:
- lighttpd.conf
- enable mod_rewrite in server modules
- add below code as rewriting (first line should use +=, not =, if you have other rewrite-once rules, or append these to the ones you have):
url.rewrite-once = (
# What does this line do? It seems to prevent any page with a dot in its
# name from being rewritten, unless it's preceded by a colon.
# "(^/wiki/[^:]*[\./].*)" => "$1",
"^/wiki/([^?]*)(?:\?(.*))?" => "/w/index.php?title=$1&$2",
"^/wiki" => "/w/index.php",
)
-
- now edit /w/LocalSettings.php
$wgScriptPath = "/w"; $wgArticlePath = "/wiki/$1";
After restarting lighttpd it should work. The code is not fully rewriting the code cause pages lik Linking to this page or Printable version etc are linked to /w/index.php?... anyway. So this code requires tweaking by more experienced users.
[edit] Lighttpd rewrite #2
WARNING: This rewrite is flawed because its real and virtual paths overlap. You will not be able to access api.php without modifications to the rewrite rules, and you will not be able to create a page called index.php
Here a working setup for pretty URLs like http://florian-konnertz.de/wiki/Hauptseite
- MW root is in doc root subfolder 'wiki/'
- lighttpd-1.4.13
- mediawiki-1.11.0
- In LocalSettings.php:
$wgScriptPath = "/wiki"; // where the wiki root is under the doc root $wgArticlePath = "/wiki/$1"; // how rel.urls are prefixed on the page $wgUsePathInfo = false; // if MW determines the page by URL path and not only by URL query args
- lighttpd.conf:
url.rewrite-once = (
"^/wiki/[sS]kins.*$" => "$0",
"^/wiki/([^\?]*)$" => "/wiki/index.php?title=$1",
)
- First line returns subrequest urls to css files etc. unchanged.
- Second line checks for URLs without "?" (assumes it's a simple URL like above)
- URLs which pass both are left unchanged, ie. http://florian-konnertz.de/wiki/index.php?title=Spezial:Abmelden&returnto=Hauptseite
Not completely sure if i didnt miss a possible case... hope this helps groovehunter 05:37, 28 May 2008 (UTC)

