Use short URL to refer to MediaWiki site with Apache virtual host

452 Views Asked by At

My setup on Apache:

  • /var/www/sandbox.example.org/wiki
  • I have a permanent rewrite from http://sandbox.example.org to https://sandbox.example.org; there is an http config file and an https config file
  • In Apache config files: DocumentRoot /var/www/sandbox.example.org/wiki
  • In Apache config files: DirectoryIndex index.php

I put Mediawiki in the /var/www/sandbox.example.org/wiki folder and then did the installation.

LocalSettings.php got automatically: $wgScriptPath = "";

As URL in the browser, I get: https://sandbox.example.org/index.php?title=MainPage

What I want: https://sandbox.example.org/wiki/MainPage

I followed / tried instructions on https://www.mediawiki.org/wiki/Manual:Short_URL/Apache, but with no effect.

How to do this?

1

There are 1 best solutions below

1
J. Vos On

Found the solution! For the ones who are interested:

In the virtual host configuration file, there is among others within the <VirtualHost *:80> tag:

DocumentRoot /var/www/sandbox.example.org
DirectoryIndex w/index.php

RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

And in the LocalSettings.php of the MediaWiki installation:

$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

So now I have: http://sandbox.example.org/wiki/MainPage instead of http://sandbox.example.org/w/index.php?title=MainPage.