Manual:Short URL/wiki.example.com/Page title--difficult

From MediaWiki.org

Jump to: navigation, search

Contents

[edit] Subdomain

[edit] Subdomain with Subdirectory in Article URL

You can make MediaWiki use a subdomain like "wiki.example.com/foo". This assumes that you already have a subdomain ready; if not, set one up or contact your host.

  1. Use one of the methods above to reduce "/wiki/index.php?title=foo" to "/wiki/foo".
  2. Add $wgServer to LocalSettings.php with your subdomain.
    $wgServer = "http://subdomain.example.com";
    
  3. Blank the value of $wgScriptPath in LocalSettings.php, so that MediaWiki links to the domain.
    $wgScriptPath = "";
    

[edit] LocalSettings.php

/var/www/wikistatic/wiki/LocalSettings.php

Note: these lines may be interspersed among others. If these variables are not in the file, add them in.

$wgScriptPath = "http://static.wiki.example.com/wiki";
 
$wgArticlePath = "http://wiki.example.com/$1";

[edit] index.php

/var/www/wiki/index.php

<?php
chdir('/var/www/wikistatic/wiki/');
include('index.php');
?>

The meaning of the two middle lines are:

  1. Set the working directory to that of the other subdomain (replace that path with the correct absolute path to the MediaWiki files your server).
  2. Include the index.php file from that directory.

[edit] .htaccess

/var/www/wiki/.htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^.*$ index.php?title=$0 [L,QSA]

The meaning of these three lines are:

  1. Enable URL re-writing
  2. Tell the re-writer that we are using the root directory of the subdomain
  3. Send all requests to the index.php file (in this directory/subdomain)

Please note: This is a hack, and the MediaWiki documentation does not seem to say anything about having full URLs including domain names in the wgScriptPath and wgArticlePath variables, but it appears to work in version 1.9.3. The only problem should be if any pages prefix wgServer onto either of the two variables shown above in LocalSettings.php.

The http://static.wiki.example.com subdomain eliminates the problems with the other subdomain approaches, because the filenames that would conflict there are in a totally different namespaces when using this approach.

Personal tools