Manual:Short URL/wiki.example.com/Page title--Subdomain with no Subdirectory in Article URL

From MediaWiki.org
Jump to: navigation, search

Contents

[edit] Subdomain

[edit] Subdomain with no Subdirectory in Article URL

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 (.+) /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       = "";
$wgArticlePath      = "/$1";
$wgUsePathInfo = false;

[edit] Localization

Note that if your setup is not an English version, you must change the .htaccess Rewrite rules according to the name of the Title Page in your language. The 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 ^/*$ /index.php?title=Заглавная_страница [L,QSA]
# anything else is to be treated as a title
RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]

note russian text Заглавная_страница is Windows-1251 encoded.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox