Pretty URLs aren't working after upgrade to Mediawiki 1.24.2

382 views Asked by At

So I am moving a Mediawiki site of mine to a new server. The version 1.20.3 worked fine on the old server running Ubuntu 12.04. However, when I copied everything over to my new server running Ubuntu 14.04 it didn't. So after messing with it for a while I decided it might be easier to simply upgrade from 1.20.3 to 1.24.2 at the same time.

I got 1.24.2. from the Mediawiki download site. Unzipped it. Ran maintenance/upgrade.php and copied all my extensions, images, uploads, skins, logos, and LocalSettings.php files from 1.20.3 to 1.24.2. The 1.24.2 site works fine so long as I use http://wikis.controltheorypro.com/index.php?title=Main_Page but does not when I use http://wikis.controltheorypro.com/Main_Page or http://wikis.controltheorypro.com/ (which redirects to http://wikis.controltheorypro.com/Main_Page).

The redirects worked fine for 1.20.3 on the old server. And something in LocalSetting.php or the DB is still telling Mediawiki to use the pretty URLs because all of the URLs on my Main page are lacking the index.php?title= portion of the URL.

I'm a fairly competent PHP and server person but this is an old site and I only ever really deal with it when I move servers. It's a site that I put a lot of effort into several years ago. I'd have killed it by now but it seems to get a lot of traffic from students so I keep it alive.

I have attempted several solutions via Google and the Mediawiki site.

My .htaccess is a mess at this point but here it is:

#RewriteEngine on

#RewriteCond %{HTTP_HOST} ^controltheorypro.com$ [OR]
#RewriteCond %{HTTP_HOST} ^www.controltheorypro.com$
#RewriteRule ^/?$ "http\:\/\/wikis\.controltheorypro\.com" [R=301,L]

<IfModule mod_rewrite.c>
# Turn on mod_rewrite
RewriteEngine On

# Virtual path to index.php
RewriteRule ^/?(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]
RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]

# If you are converting from a static site to a wiki,
# you'll want to make redirections to the new article.
#RewriteRule ^old-file.html$ http://www.example.com/New_Article [R=permanent,L]

# This hack lets you essentially gets rid of the redirection
# to "Main Page".  Conversely, if you go to http://www.example.com/Main_Page,
# it sends an permanent external redirection to http://www.example.com/.
RewriteRule ^Main_Page$ http://wikis.controltheorypro.com/ [R=permanent,L]
RewriteRule ^$ /var/www/html/CTP/mediawiki-1.24.2/index.php?title=Main_Page&redirect=no [QSA,L]

RewriteRule ^/new/rss http://wikis.controltheorypro.com/index.php?title=Special:NewPages&feed=rss [QSA,L]
RewriteRule ^/do/([a-z]*)/(.*)$ /var/www/html/CTP/mediawiki-1.24.2/index.php?action=$1&title=$2 [QSA,L]

# Finally, if we've gotten this far, process it as if it's an article,
# UNLESS it's a physical file/directory/symlink.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /var/www/html/CTP/mediawiki-1.24.2/index.php?title=$1 [QSA,L]
</IfModule>

LocalSettings.php:

<?php
# This file was automatically generated by the MediaWiki 1.20.3
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# http://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
        exit;
}

## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename      = "ControlTheoryPro.com";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath       = "";
$wgScriptExtension  = ".php";

## Added by me to enable pretty permalinks
$wgArticlePath = "$wgScriptPath/$1";
$wgUsePathInfo = true;

## The protocol and server name to use in fully-qualified URLs
$wgServer           = "http://wikis.controltheorypro.com";

## The relative URL path to the skins directory
$wgStylePath        = $wgScriptPath . "/skins";

## The relative URL path to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo             = $wgServer . "/logo.gif"; // "/wiki_symbol_default_size.png"; // "$wgStylePath/common/images/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail      = true;
$wgEnableUserEmail  = true; # UPO

$wgEmergencyContact = "[email protected]";
$wgPasswordSender   = "[email protected]";

$wgEnotifUserTalk      = false; # UPO
$wgEnotifWatchlist     = false; # UPO
$wgEmailAuthentication = true;

## Database settings
....

# MySQL specific settings
$wgDBprefix         = "";

# MySQL table options to use during installation or update
$wgDBTableOptions   = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

# Experimental charset support for MySQL 5.0.
$wgDBmysql5 = false;

## Shared memory settings
$wgMainCacheType    = CACHE_MEMCACHED;
$wgMemCachedServers = array( '127.0.0.1:11211' );

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads  = true;
#$wgUseImageMagick = true;
#$wgImageMagickConvertCommand = "/usr/bin/convert";

# InstantCommons allows wiki to use images from http://commons.wikimedia.org
$wgUseInstantCommons  = true;

## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale
$wgShellLocale = "en_US.utf8";

## If you want to use image uploads under safe mode,
## create the directories images/archive, images/thumb and
## images/temp, and make them all writable. Then uncomment
## this, if it's not already uncommented:
#$wgHashedUploadDirectory = false;

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
#$wgCacheDirectory = "$IP/cache";

# Site language code, should be one of the list in ./languages/Names.php
$wgLanguageCode = "en";

$wgSecretKey = ...;

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = ...;

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':
$wgDefaultSkin = "gumaxdd"; // "vector";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl  = "http://creativecommons.org/licenses/by-nc-sa/3.0/";
$wgRightsText = "Creative Commons Attribution Non-Commercial Share Alike";
$wgRightsIcon = "{$wgStylePath}/common/images/cc-by-nc-sa.png";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";            // Manually added - GTS 04/11/13

# Query string length limit for ResourceLoader. You should only set this if
# your web server has a query string length limit (then set it to that limit),
# or if you have suhosin.get.max_value_length set in php.ini (then set it to
# that value)
$wgResourceLoaderMaxQueryLength = -1;

# The following permissions were set based on your choice in the installer
$wgGroupPermissions['*']['edit'] = false;

# Enabled Extensions. Most extensions are enabled by including the base extension file here
# but check specific extension documentation for more details
# The following extensions were automatically enabled:
require_once( "$IP/extensions/ConfirmEdit/ConfirmEdit.php" );
require_once( "$IP/extensions/Gadgets/Gadgets.php" );
require_once( "$IP/extensions/Math/Math.php" );
require_once( "$IP/extensions/Nuke/Nuke.php" );
require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );
require_once( "$IP/extensions/Renameuser/Renameuser.php" );
require_once( "$IP/extensions/Vector/Vector.php" );
require_once( "$IP/extensions/WikiEditor/WikiEditor.php" );


# End of automatically generated settings.
# Add more configuration options below.

# Action Paths - should help with SPAM and pretty up the URLs
#               These require a a RewriteRule in the .htaccess though see
#               http://www.mediawiki.org/wiki/User:Fo0bar/MediaWiki_root_articles
#               for details.
#
#               These did not work at first because I had messed with $wgScriptPath
#               be careful.

/*
#$wgArticlePath = "/$1";

foreach($wgActions as $action => $value) {
  if($value === false) { continue; }
  if($action == 'raw') { continue; }
  $wgActionPaths[$action] = "$wgScriptPath/do/$action/$1";
}
$wgActionPaths['view'] = $wgArticlePath;
*/

# FavIcon
$wgFavicon = $wgScriptPath . "/favicon.ico";

# Don't allow the site to be iframed
$wgBreakFrames = TRUE;
# Add rel="no follow" to all links
$wgNoFollowLinks = TRUE;                // TRUE by default as of 04/11/13 but just in case

# Exceptions to the default rel="no follow" rule
$wgNoFollowDomainExceptions = array(...

# Add Equations to the Site - the URL to mathtex is in Math.body.php (function renderMath)
require_once("$IP/extensions/Math/Math.php");

# Add CAPTCHA
#               Config: http://www.mediawiki.org/wiki/Extension:ConfirmEdit
require_once("$IP/extensions/ConfirmEdit/ConfirmEdit.php");
require_once("$IP/extensions/ConfirmEdit/ReCaptcha.php");
$wgCaptchaClass = 'ReCaptcha';
$wgReCaptchaPublicKey = ...;
$wgReCaptchaPrivateKey = ...;

        # User permissions wrt CAPTCHA
        $wgGroupPermissions['*'            ]['skipcaptcha'] = false;
        $wgGroupPermissions['user'         ]['skipcaptcha'] = false;
        $wgGroupPermissions['autoconfirmed']['skipcaptcha'] = false;
        $wgGroupPermissions['bot'          ]['skipcaptcha'] = true; // registered bots
        $wgGroupPermissions['sysop'        ]['skipcaptcha'] = true;

        # Action permission wrt CAPTCHA
        $wgCaptchaTriggers['edit']          = false;            // Doesn't show CAPTCHA
        $wgCaptchaTriggers['create']        = true;
        $wgCaptchaTriggers['addurl']        = true;             // Shows CAPTCHA
        $wgCaptchaTriggers['createaccount'] = true;
        $wgCaptchaTriggers['badlogin']      = true;

        # Can also be configured to whitelist by IPs and Confirmed Emails

# Filter out all pages/edits/etc that include the following
#               Ref & more examples: http://www.mediawiki.org/wiki/Manual:$wgSpamRegex
$wgSpamRegex = "/".                        # The "/" is the opening wrapper
                "s-e-x|zoofilia|sexyongpin|grusskarte|geburtstagskarten|animalsex|".
                "sex-with|dogsex|adultchat|adultlive|camsex|sexcam|livesex|sexchat|".
                "chatsex|onlinesex|adultporn|adultvideo|adultweb.|hardcoresex|hardcoreporn|".
                "teenporn|xxxporn|lesbiansex|livegirl|livenude|livesex|livevideo|camgirl|".
                "spycam|voyeursex|casino-online|online-casino|kontaktlinsen|cheapest-phone|".
                "laser-eye|eye-laser|fuelcellmarket|lasikclinic|cragrats|parishilton|".
                "paris-hilton|paris-tape|2large|fuel-dispenser|fueling-dispenser|huojia|".
                "jinxinghj|telematicsone|telematiksone|a-mortgage|diamondabrasives|".
                "reuterbrook|sex-plugin|sex-zone|lazy-stars|eblja|liuhecai|".
                "viagra|cialis|levitra|".
                "airsoft|estate|facebook|loan|credit|garden|porn|sunless|landscaping|coupons|wartol|xbox|playstation|".
                "buy-viagra|-cialis|-levitra|boy-and-girl-kissing|". # These match spammy words
                "dirare\.com|".           # This matches dirare.com a spammer's domain name
                "overflow\s*:\s*auto|".   # This matches against overflow:auto (regardless of whitespace on either side of the colon)
                "height\s*:\s*[0-4]px|".  # This matches against height:0px (most CSS hidden spam) (regardless of whitespace on either side of the colon)
                "==<center>\[|".           # This matches some recent spam related to starsearchtool.com and friends
                "\<\s*a\s*href|".         # This blocks all href links entirely, forcing wiki syntax
                "display\s*:\s*none".     # This matches against display:none (regardless of whitespace on either side of the colon)
                "/i";                     # The "/" ends the regular expression and the "i" switch which follows makes the test case-insensitive
                                          # The "\s" matches whitespace
                                          # The "*" is a repeater (zero or more times)
                                          # The "\s*" means to look for 0 or more amount of whitespace

# Attempt to eliminate the bots
require_once( "$IP/extensions/AntiBot/AntiBot.php" );

# Citations/References
require_once("$IP/extensions/Cite/Cite.php");

# Category Tree
#               Config: http://www.mediawiki.org/wiki/Extension:CategoryTree
$wgUseAjax = true;
require_once( "$IP/extensions/CategoryTree/CategoryTree.php" );

# Wiki SEO
# Details: http://www.mediawiki.org/wiki/Extension:WikiSEO
#       Example: {{#seo: title=Your page title | titlemode= append | keywords=these,are,your,keywords | description=Your meta description }}
include_once("$IP/extensions/WikiSEO/WikiSEO.setup.php");
# Add Relation Links to Header
# Details: http://www.mediawiki.org/wiki/Extension:RelationLinks
require_once( "$IP/extensions/RelationLinks/RelationLinks.php" );

# Amazon - Doesn't make me any money but it will allow users to easily buy the
#               books
include("extensions/Amazon.php");

# Provide Section Heading Numbers
$wgDefaultUserOptions['numberheadings'] = 1;

# Provide access to outside feeds
require_once( "$IP/extensions/WikiArticleFeeds/WikiArticleFeeds.php" );
require_once( "$IP/extensions/RSS/RSS.php" );

$wgFeed = TRUE;                                                                                                                                 // Use Feed
$wgAdvertisedFeedTypes = array('rss', 'atom');  // Advertise RSS and Atom
$wgFeedCacheTimeout = 3600;                                                                                     // 1 Hour (3600 sec) between feed cache refre$
$wgFeedLimit = 15;                                                                                                                      // Number of results $

#       Dynamic Page List
#               Config: http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia)
require_once("$IP/extensions/intersection/DynamicPageList.php");
# Show Exceptions for install/dev purposes only - GTS 04/11/13
#$wgShowExceptionDetails = true;

// Prevent New Account Creation (SPAM) - GTS 06/10/13
//$wgGroupPermissions['*']['createaccount'] = false;


// Disables write access (page editing and creation) by default, creates a group named "Write", and grants it
//      write access. Users can be manually added to this group via Special:UserRights.
//      http://www.mediawiki.org/wiki/Manual:User_rights
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createpage'] = false;
$wgGroupPermissions['user']['edit'] = false;
$wgGroupPermissions['user']['createpage'] = false;
$wgGroupPermissions['Write']['edit'] = true;
$wgGroupPermissions['Write' ]['createpage'] = true;
$wgGroupPermissions['sysop']['edit'] = true;
$wgGroupPermissions['sysop' ]['createpage'] = true;

-------- Solution ---------

I added the following to /etc/apache2/sites-available/wikis.controltheorypro.com.conf and then restart the Apache server.

# MediaWiki Security
        <Directory /var/www/html/CTP/mediawiki-1.24.2/>
                # Ignore .htaccess files
                AllowOverride All

                # Serve HTML as plaintext, don't execute SHTML
                #AddType text/plain .html .htm .shtml .php

                # Don't run arbitrary PHP code.
                #php_admin_flag engine off

                # If you've other scripting languages, disable them too.
        </Directory>

        # MediaWiki Uploads Security
        <Directory /var/www/html/CTP/mediawiki-1.24.2/images>
                # Ignore .htaccess files
                AllowOverride None

                # Serve HTML as plaintext, don't execute SHTML
                AddType text/plain .html .htm .shtml .php

                # Don't run arbitrary PHP code.
                php_admin_flag engine off

                # If you've other scripting languages, disable them too.
        </Directory>
1

There are 1 answers

1
Florian On BEST ANSWER

Make sure, that you checked the following points: - the mod_rewrite module is enabled - you allow the htaccess to overwrite the settings you want (check, if the AllowOverwride directive is set, e.g. (that would be the easiest value) to all, see http://httpd.apache.org/docs/current/de/mod/core.html#allowoverride

# your directory definition
AllowOverwride All
# your other definitions

After that and a restart/reload, the short URLs should work.