Manual:Short URL/wiki/Page title -- Lighttpd rewrite--root access
Warning: This Short URL page contains bad advice on how to configure your server that could lead to some pages on your wiki not working and/or may cause you issues while upgrading. This guide remains simply because an official guide on how to configure short URLs on this wiki has not been created yet. |
Lighttpd rewrite #1
[edit]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
Please note the installation path (/w/ above) and the virtual path to access articles (/wiki/ above) must be different, or the styles won't load at all (and other issues, with extensions for instance), as explained in the main 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-if-not-file = ( "^/wiki/(mw-)?config/?" => "$0", "^/wiki/([^?]*)(?:\?(.*))?" => "/w/index.php?title=$1&$2", "^/wiki/([^?]*)" => "/w/index.php?title=$1", "^/wiki$" => "/w/index.php", # to avoid 404 when the user types /wiki instead of /wiki/ )
- now edit /w/LocalSettings.php
$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
After restarting lighttpd it should work.
Lighttpd rewrite #2
[edit]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://example.com/wiki/Main_page
- 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/(images|skins)/(.*)" => "$0", "^/wiki/(mw-)?config/?(.*)" => "$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)
Lighttpd redirect and 404 handling (method #3)
[edit]- in lighttpd.conf:
$HTTP["host"] == "www.yoursite.tld" { $HTTP["url"] =~ "^/wiki/" { server.error-handler-404 = "/w/index.php" } }
- in LocalSettings.php:
$wgScriptPath = "/w"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;