For my wiki-farm I've been using this technique for clean URLs with Apache:
.htaccess Options FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php/title=$1 [L,QSA]
LocalSettings.php $wgScriptPath = "/wiki"; $wgArticlePath = "/$1";
Same as detailed here: http://www.mediawiki.org/wiki/Manual:Short_URL#.htaccess_2
After upgrading to 1.11 viewing the pages still work, but when I attempt to edit a page it insists on creating and editing a new page called "Index.php".
Any ideas?
On Sep 20, 2007, at 5:46 PM, Trevor Wennblom wrote:
After upgrading to 1.11 viewing the pages still work, but when I attempt to edit a page it insists on creating and editing a new page called "Index.php".
Here's the fix - add to LocalSettings.php: $wgUsePathInfo = false;
On Sep 20, 2007, at 8:59 PM, Trevor Wennblom wrote:
Here's the fix - add to LocalSettings.php: $wgUsePathInfo = false;
I think this is what changed (scan for path info):
diff -uN mediawiki-1.10.2/includes/WebRequest.php mediawiki-1.11.0/ includes/WebRequest.php
--- mediawiki-1.10.2/includes/WebRequest.php 2007-04-24 01:53:31.000000000 -0500 +++ mediawiki-1.11.0/includes/WebRequest.php 2007-06-28 20:19:14.000000000 -0500 @@ -44,19 +44,95 @@ class WebRequest { function __construct() { $this->checkMagicQuotes(); + } + + /** + * Check for title, action, and/or variant data in the URL + * and interpolate it into the GET variables. + * This should only be run after $wgContLang is available, + * as we may need the list of language variants to determine + * available variant URLs. + */ + function interpolateTitle() { global $wgUsePathInfo; if ( $wgUsePathInfo ) { - if ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER ['ORIG_PATH_INFO'] != '' ) { - # Mangled PATH_INFO - # http://bugs.php.net/bug.php?id=31892 - # Also reported when ini_get('cgi.fix_pathinfo')==false - $_GET['title'] = $_REQUEST['title'] = substr( $_SERVER ['ORIG_PATH_INFO'], 1 ); - } elseif ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER ['PATH_INFO'] != '') && $wgUsePathInfo ) { - $_GET['title'] = $_REQUEST['title'] = substr( $_SERVER ['PATH_INFO'], 1 ); + // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892 + // And also by Apache 2.x, double slashes are converted to single slashes. + // So we will use REQUEST_URI if possible. + $matches = array(); + if ( !empty( $_SERVER['REQUEST_URI'] ) ) { + // Slurp out the path portion to examine... + $url = $_SERVER['REQUEST_URI']; + if ( !preg_match( '!^https?://!', $url ) ) { + $url = 'http://unused' . $url; + } + $a = parse_url( $url ); + if( $a ) { + $path = $a['path']; + + global $wgArticlePath; + $matches = $this->extractTitle( $path, $wgArticlePath ); + + global $wgActionPaths; + if( !$matches && $wgActionPaths) { + $matches = $this->extractTitle( $path, $wgActionPaths, 'action' ); + } + + global $wgVariantArticlePath, $wgContLang; + if( !$matches && $wgVariantArticlePath ) { + $variantPaths = array(); + foreach( $wgContLang->getVariants() as $variant ) { + $variantPaths[$variant] = + str_replace( '$2', $variant, $wgVariantArticlePath ); + } + $matches = $this->extractTitle( $path, $variantPaths, 'variant' ); + } + } + } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER ['ORIG_PATH_INFO'] != '' ) { + // Mangled PATH_INFO + // http://bugs.php.net/bug.php?id=31892 + // Also reported when ini_get('cgi.fix_pathinfo')==false + $matches['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 ); + + } elseif ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER ['PATH_INFO'] != '') ) { + // Regular old PATH_INFO yay + $matches['title'] = substr( $_SERVER['PATH_INFO'], 1 ); + } + foreach( $matches as $key => $val) { + $_GET[$key] = $_REQUEST[$key] = $val; } } } + /** + * Internal URL rewriting function; tries to extract page title and, + * optionally, one other fixed parameter value from a URL path. + * + * @param string $path the URL path given from the client + * @param array $bases one or more URLs, optionally with $1 at the end + * @param string $key if provided, the matching key in $bases will be + * passed on as the value of this URL parameter + * @return array of URL variables to interpolate; empty if no match + */ + private function extractTitle( $path, $bases, $key=false ) { + foreach( (array)$bases as $keyValue => $base ) { + // Find the part after $wgArticlePath + $base = str_replace( '$1', '', $base ); + $baseLen = strlen( $base ); + if( substr( $path, 0, $baseLen ) == $base ) { + $raw = substr( $path, $baseLen ); + if( $raw !== '' ) { + $matches = array( 'title' => rawurldecode( $raw ) ); + if( $key ) { + $matches[$key] = $keyValue; + } + return $matches; + } + } + } + return array(); + } + private $_response;
/** @@ -543,4 +619,4 @@
}
-?> +
mediawiki-l@lists.wikimedia.org