praiseHellRaiseDale
praiseHellRaiseDale

Reputation: 2270

How do I set short URL's for MediaWiki?

I used this guide to install mediawiki version 1.27.0. The install went great, and everything is working.

Currently in the url it still has the index.php in the url, like this: http://example.com/index.php/Main_Page

There is documentation here, and here, but there are sections of these instructions that don't make sense to me.

Here's what I'm using:


I'll go through the instructions, and list the problems I'm having.

1. In the instructions they assume that your mediawiki install is setup in /w.

Well, mine is installed here /var/www/html/

2. Find the right apache2 files

I have root access so I'm assuming I will be using two files /etc/apache2/apache2.conf for the AllowOverride All, and /etc/apache2/sites-available/000-default.conf to edit anything related to the VirtualHost section.

3. Setting the rewrite rules

In my /etc/apache2/sites-available/000-default.conf file, in the <VirtualHost *:80> section, I added these lines

RewriteEngine On

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

I understand that this shouldn't work with my setup, because it's using the /wiki, and /w filepaths, and those don't even exist, but I'm not sure what I should put.

4. Change LocalSettings.php

This step also has me confused for the same reason. It says to set $wgScriptPath = "/w";, which is a directory I don't have, and set $wgArticlePath = "/wiki/$1";, which is not only a directory I don't have, but that variable doesn't even exist in the LocalSettings.php file.


I think if I understood the first step, of changing my directory to /w, then I could get the rest, but obviously, I can't change /var/www/html, to /w, without breaking everything. Thanks in advance.

Upvotes: 4

Views: 2893

Answers (1)

lin
lin

Reputation: 18402

For all who are not running MediaWiki in the default subdirectoy on your HOST (means not like /w/ or /wiki/) configure your .htaccess like:

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ index.php [L]

And add the article path to your LocalSettings.php:

$wgArticlePath = "/$1";

Upvotes: 9

Related Questions