Mobile app version of vmapp.org
Login or Join
Cugini213

: MediaWiki configuration - strange redirect behaviour after form POST I've recently setup a wiki using MediaWiki but am having the toughest time getting the ShortURL configuration working properly

@Cugini213

Posted in: #Htaccess #Mediawiki #Php #Redirects

I've recently setup a wiki using MediaWiki but am having the toughest time getting the ShortURL configuration working properly (for example, so that pages appear as Main_Page instead of index.php?title=Main_Page. It's installed inside a subfolder of a subdomain (e.g. intranet.example.com/mediawiki/), and at present my .htaccess file in this mediawiki folder has the following lines (I've created this file, it's not shipped with MediaWiki):

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/mediawiki/.*$
RewriteCond %{REQUEST_URI} !^/mediawiki/index.php.*$
RewriteCond %{REQUEST_URI} !^/mediawiki/load.php.*$
RewriteCond %{REQUEST_URI} !^/mediawiki/skins/.*$
RewriteRule ^(.*)$ index.php/ [L]


And the LocalSettings.php has the following lines which affect the routing of page requests:

$wgScriptPath = "/mediawiki";
$wgScriptExtension = ".php";
$wgArticlePath = "/mediawiki/";
$wgUsePathInfo = true;
$wgServer = "http://intranet.example.com/";


I've tried experimenting with these options, removing and adding slashes in different places to try and find the best working configuration and for the most-part it's all working as you might expect, apart from the redirects that happen following a form post (e.g. after logging in/out or editing a page).

In these circumstances the user is redirected every time to intranet.example.com//mediawiki/Main_Page, even when Main_Page is not the current page being worked on (very frustrating) and notice the extra forward slash? This causes an HTTP 404 error.

On an edit page the form post action URL is /mediawiki/index.php?title=Main_Page&action=submit, which looks fine to me. The issue seems to be with the internal redirect that happens after the processing is complete as the page changes do save properly.

I don't know if it gives any clues but I notice from the generated source that the stylesheets and javascript links begin with intranet.example.com//mediawiki/load.php?... with that second forward slash reappearing again (though these resources still load fine somehow).

As far as I can tell I've followed the MediaWiki official installation and configuration instructions correctly. Any help appreciated! It's obviously not robust enough with its current behaviour. Non-tech users aren't going to know they need to edit the URL after every time the redirect breaks!



If I remove the starting forward slash from $wgArticlePath then requesting intranet.example.com/mediawiki/ leads to the following redirects in my apache log:

"GET /mediawiki/ HTTP/1.1" 301 -
"GET /mediawiki/mediawiki/Main_Page HTTP/1.1" 301 -
"GET /mediawiki/mediawiki/mediawiki/Mediawiki/Main_Page HTTP/1.1" 301 -
"GET /mediawiki/mediawiki/mediawiki/Mediawiki/mediawiki/Mediawiki/mediawiki/Mediawiki/Main_Page HTTP/1.1" 301 -


and so on until eventually I get a "Bad title" WikiPedia page returned to the browser.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cugini213

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini213

The solution now working and tested - in the LocalSettings.php file, shared in case anyone else has trouble with this:

$wgScriptPath = "/mediawiki";
$wgScriptExtension = ".php";
$wgArticlePath = "/mediawiki/";
$wgUsePathInfo = true;
$wgServer = "http://intranet.example.com";


The problem was caused by a forward slash on the end of the $wgServer parameter.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme