Manual:Short URL/wiki.php/Page title -- No root No htaccess
From MediaWiki.org
[edit] Url Parsing without root access or .htaccess
You can rewrite your URLs
from: subdomain.example.com/w/index.php?title=page&action=action
to: subdomain.example.com/wiki.php/action/page
or: subddomain.example.com/wiki.php/page/action (NOT RECOMMENDED - Mediawiki doesn't automatically URLencode slashes in page names, so it messes up the URL rewriting.)
Its simple with the php script enclosed at the bottom of this page.
Simply change or leave 3 variables.
- The installation directory of mediawiki, or any wiki really
- The divider used to separate action from page from whatever else
- an array of url sections eg. array("action","title"); will turn wiki.php/view/Main_Page
to /w/index.php?title=Main_Page&action=view
Special pages will get passed completely and directly to index.php as a title, because special pages cannot have normal wiki actions, and that they commonly have trailing slashes or other query strings attached (no pun intended) that are translated by the special page.
Take Special:Whatlinkshere/Main_Page for example. It has its own trailing slash and variable that is parsed by the special page itself.
All other pages URLs are parsed according to the array as mentioned above.
wiki.php
<?php //Created By Jeremy Rumble; //Version 2.0.1 //Improving and distributing this script is allowed, but please leave the creators name. #Variables; ##The Path to the wiki installation, relative to this file or absolute.; ##Absolute is better especially if this file is included in another file.; $installPath = "./w"; ##The Seperator for the Url.; ## eg. http://www.example.com/wiki.php/Page-action-skin; ## or http://www.example.com/wiki.php/Page/action/skin; ## Usually a / or a _ or a -; $URL_Seperator = "/"; ##The functions for each part of the URL; ## wiki.php/pageTitle/action/skin; ## there can be more; $URL_Parts = array("action","title"); //========================Do Not Edit Below This Line==========================; if(!isset($_SERVER['ORIG_PATH_INFO'])) { $requestUri = $_SERVER['REQUEST_URI']; if(strpos($requestUri, '/', 1)!==''&&strpos($requestUri, '/', 1)!==NULL&&strpos($requestUri, '/', 1)) { $requestUri = substr($requestUri, strpos($requestUri, '/', 1)); $_SERVER['ORIG_PATH_INFO'] = $requestUri; } else { $_SERVER['ORIG_PATH_INFO'] = ""; } } if(!strpos($_SERVER['ORIG_PATH_INFO'],"Special:")) { if (isset($_SERVER['ORIG_PATH_INFO'])) { $url = substr($_SERVER['ORIG_PATH_INFO'], 1); $urlParts = explode($URL_Seperator, $url); $urlPartsCount = count($urlParts); $i=0; foreach($URL_Parts as $U_P) { if(isset($urlParts[$i])&&$urlParts[$i]!==''){$_GET[$U_P]=$urlParts[$i];} $i++; } } } else { $url = substr($_SERVER['ORIG_PATH_INFO'], 1); $urlParts = explode($URL_Seperator, $url); $urlPartsCount = count($urlParts); if(isset($url)&&$url!==''){$_GET["title"]=$url;} } chdir($installPath); include("index.php"); ?>
LocalSettings.php Snippet
$wgScriptPath = "/w"; $wgActionPaths["view"]="http://127.0.0.1/wiki.php/$1/view"; $wgActionPaths["edit"]="http://127.0.0.1/wiki.php/$1/edit"; $wgActionPaths["watch"]="http://127.0.0.1/wiki.php/$1/watch"; $wgActionPaths["unwatch"]="http://127.0.0.1/wiki.php/$1/unwatch"; $wgActionPaths["delete"]="http://127.0.0.1/wiki.php/$1/delete"; $wgActionPaths["revert"]="http://127.0.0.1/wiki.php/$1/revert"; $wgActionPaths["rollback"]="http://127.0.0.1/wiki.php/$1/rollback"; $wgActionPaths["protect"]="http://127.0.0.1/wiki.php/$1/protect"; $wgActionPaths["unprotect"]="http://127.0.0.1/wiki.php/$1/unprotect"; $wgActionPaths["info"]="http://127.0.0.1/wiki.php/$1/info"; $wgActionPaths["markpatrolled"]="http://127.0.0.1/wiki.php/$1/markpatrolled"; $wgActionPaths["validate"]="http://127.0.0.1/wiki.php/$1/validate"; $wgActionPaths["render"]="http://127.0.0.1/wiki.php/$1/render"; $wgActionPaths["deletetrackback"]="http://127.0.0.1/wiki.php/$1/deletetrackback"; $wgActionPaths["print"]="http://127.0.0.1/wiki.php/$1/print"; $wgActionPaths["dublincore"]="http://127.0.0.1/wiki.php/$1/dublincore"; $wgActionPaths["creativecommons"]="http://127.0.0.1/wiki.php/$1/creativecommons"; $wgActionPaths["credits"]="http://127.0.0.1/wiki.php/$1/credits"; $wgActionPaths["submit"]="http://127.0.0.1/wiki.php/$1/submit"; $wgActionPaths["viewsource"]="http://127.0.0.1/wiki.php/$1/viewsource"; $wgActionPaths["history"]="http://127.0.0.1/wiki.php/$1/history"; $wgActionPaths["purge"]="http://127.0.0.1/wiki.php/$1/purge"; $wgArticlePath = "http://127.0.0.1/wiki.php/$1";