MediaWiki: Changing Index.php
-
Hi all. New install of MediaWiki and I'm trying to change it so instead of
www.sitename.com/index.php/article
it'swww.sitename.com/wiki/article
. I have done this before, I just cannot remember what the heck I did.I'm using https://shorturls.redwerks.org and the instruction reads: "This configuration is meant to go the same block as whatever VirtualHost or other directive you have your wiki's DocumentRoot, ServerName, etc... already defined in." Now, best I know, the wiki is installed in
/var/www/wiki/
... Is that the location it's referring to? Or is it looking for something else?The commands it's giving, in case that helps, are...
RewriteEngine On RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
-
Because I'm impatient...
The code I copy+pasted above needs to go into the appropriate .conf file, which will be located in
/etc/apache2/sites-available
... If it's a very basic MediaWiki install on, say, DigitalOceans, you might need to usedefault
ordefault.conf
. In this case, because my site waswiki.site.com
it was in a file calledsite.conf
.As per the instructions, paste that code into the
.conf
file, then move on to updating theLocalSettings.php
file, which would be in/var/www/wiki/
or whatever else. Once that is done, if you are using DigitalOceans, when you refresh your site it'll fail. 404 error. Your broke literally everything. Awesome, right?You need to enable
mod_rewrite
for Apache. Do that, you can check out the DigitalOceans guide. Really, it's just two commands. -
@skew Oh cool I was going to give you a shout when I got home because I kinda munged together some of that apache config...
-
@ifrit You are the best terrifying fire spirit.
-
... and now to see if I can make this work on mine using CentOS.
-
@bobotron I haven't the slightest idea what CentOS is... Your version of Linux? I don't think it should much matter...
But honestly it's ridiculous that MediaWiki does this. The /index.php/ is so ugly, and they don't even use it on their own site. Like, why have this be how the application installs? I don't know. Harumph, I say.
Anyways, hit me up on here and I can pass you my discord and try to help, but mostly I was just bumping around in the dark promising @Cobaltasaurus I'd break her stuff.
-
That code block goes into your /var/www/wiki/ folder, and should be newly created as:
.htaccess
It doesn't go into the site.conf (or default.conf file if you are using that).
In the site.conf or (default.conf file if you're using that) file, you just want to make sure that wiki.site.com is pointing to /var/www/wiki, not /var/www/html, which is often set as the default.
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04 covers the other steps you want to peek at that address how you want to handle the site.conf file (and any other *.conf files) specifically.
This covers .htaccess and how to get it going, which has a bit more info than the other link. https://www.digitalocean.com/community/tutorials/how-to-use-the-htaccess-file
Between those two tutorials, I've been able to get multiple wikis and a default index page landing running off of one droplet, with each site in it's own folder in /var/www/ with things pointing where they need to be pointed to get people to the right places.
EDIT FOR EXAMPLE:
For an example following the two tuts above:
https://pantheogenesis.world/
https://www.pantheogenesis.world/
https://forum.pantheogenesis.world/
...and while these have nothing on them/done to them yet, note the footer text, which demonstrates they are each distinct wiki installs:
https://core.pantheogenesis.world/
https://7d.pantheogenesis.world/
https://7dstaff.pantheogenesis.world/
I puttered out and stopped giving a fuck before finishing up the intended interwiki links to pipe the data around, but eh. (The goal here is to store all RPG data on core to pipe to whatever game wiki is active as needed, with each game having a private staff wiki and a player-side wiki that can all talk to each other in a fairly fine-grained way.) They otherwise share some core files with symbolic links to what would otherwise be needlessly duplicated data; this is all stored in 'core' and linked to 7d and 7dstaff, to control edit permissions and access to data on the various wikis as needed. You don't need anything from this latter paragraph, probably, but the two linked tutorials explain all the steps needed to do what you're trying to accomplish above.IMPORTANT: Note that if you choose to use no additional text or swap in place of index.php and just go straight from the domain to the content, you will need to lock down the main namespace so no one can edit it to prevent potential conflicts. This means using custom namespaces for your various categories of things rather than dumping everything into the main namespace. Doing this also gains you access to the DPL namespace=<whatever> selection criteria, which may help prevent the need for as many categories on the wiki, and allows you to use the categories for more fine-tuning in your queries.