(bug 28242) Make url's of the form http://mediawiki.org/wiki/w:Somewhere_on_pedia...
authorBrian Wolff <bawolff@users.mediawiki.org>
Sat, 26 Mar 2011 21:06:37 +0000 (21:06 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Sat, 26 Mar 2011 21:06:37 +0000 (21:06 +0000)
This is to make google when indexing a page like http://mediawiki.org/wiki/w:Somewhere_on_pedia to report its target, not the
original url as the url of the page. This only affects urls where the (local) interwiki target is directly in the url.
Pages that contain #Redirect[[w:Somewhere_on_pedia]] will still use 302 (Temporary) redirects since such pages are by
no means permenantly redirected.

Also clarify docs on $wgDisableHardRedirects since the setting confused me.

See also google's spiel on 301 redirects http://www.google.com/support/webmasters/bin/answer.py?answer=93633

RELEASE-NOTES
includes/DefaultSettings.php
includes/Wiki.php

index 48ce1ce..423b023 100644 (file)
@@ -203,6 +203,8 @@ PHP if you have not done so prior to upgrading MediaWiki.
   page restrictions
 * Make truncate function automatically consider length of '...' string,
   since length can vary by localization.
+* (bug 28242) Make redirects generated by urls containing a local interwiki
+  prefix be a 301 instead of a 302.
 
 === API changes in 1.18 ===
 * (bug 26339) Throw warning when truncating an overlarge API result
index 35db5c8..e564eb4 100644 (file)
@@ -5320,7 +5320,9 @@ $wgDisabledActions = array();
 
 /**
  * Disable redirects to special pages and interwiki redirects, which use a 302
- * and have no "redirected from" link.
+ * and have no "redirected from" link. Note this is only for articles with #Redirect
+ * in them. URL's containing a local interwiki prefix (or a non-canonical special
+ * page name) are still hard redirected regardless of this setting.
  */
 $wgDisableHardRedirects = false;
 
index bf349cd..4a2cb10 100644 (file)
@@ -192,7 +192,8 @@ class MediaWiki {
                        }
                        /* Check for a redirect loop */
                        if( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
-                               $output->redirect( $url );
+                               // 301 so google et al report the target as the actual url.
+                               $output->redirect( $url, 301 );
                        } else {
                                $title = SpecialPage::getTitleFor( 'Badtitle' );
                                $output->setTitle( $title ); // bug 21456