Manual:Short URL/wiki.example.com/Page title--Subdomain with no Subdirectory in Article URL
From MediaWiki.org
Contents |
[edit] Subdomain
[edit] Subdomain with no Subdirectory in Article URL
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.
If you want to use something like http://wiki.example.com/Article_Title, make the following changes to .htaccess and LocalSettings.php after installing. These instructions assume MediaWiki is installed to wiki/ (under subdomain), the subdomain is only for the wiki, and that the main page is Main_Page. .htaccess lines are pretty much exactly what the owner of http://www.muscatelli.info/ posted on the discussion page.
This method also would work for main-domains (like www.example.com/Article_Title).
[edit] .htaccess
The first step is to make sure that requests for /Article_Title get interpreted correctly. Make sure your .htaccess is Allowed to Override "FileInfo" and the +FollowSymLinks Option is on. The following lines should be added to .htaccess in the root of the wiki.example.com domain:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wiki/index.php?title=$1 [L,QSA]
[edit] LocalSettings.php
Now that URLs like http://wiki.example.com/Article_Title work, all that remains is to tell MediaWiki to use those URLs. This is done by defining $wgArticlePath in LocalSettings.php. Here's an example, defined just after $wgScriptPath:
$wgScriptPath = "/wiki"; $wgArticlePath = "/$1"; $wgUsePathInfo = false;
[edit] Localization
Note, if you setup not an english version, you must change (for .htaccess) rewrite rule according name of Title Page in your language. Following sample is for russian:
RewriteEngine On # anything that contains a dot without a colon should be left alone RewriteRule ^[^:]*\. - [L] # anything that contains a slash without a colon should be left alone RewriteRule ^[^:]*\/ - [L] # redirect to main page RewriteRule ^/*$ /wiki/index.php?title=Заглавная_страница [L,QSA] # anything else is to be treated as a title RewriteRule ^(.+)$ /wiki/index.php?title=$1 [L,QSA]
note russian text Заглавная_страница is a Windows-1251 encoded.

