From: Brian Wolff Date: Sat, 26 Mar 2011 21:06:37 +0000 (+0000) Subject: (bug 28242) Make url's of the form http://mediawiki.org/wiki/w:Somewhere_on_pedia... X-Git-Tag: 1.31.0-rc.0~31170 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=1111518f51eedb3bae28e9e31f3920e41f987cee;p=lhc%2Fweb%2Fwiklou.git (bug 28242) Make url's of the form mediawiki.org/wiki/w:Somewhere_on_pedia give a 301 (permenant) redirect instead of a 302. 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 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 48ce1ce94c..423b023dd6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 35db5c8fa1..e564eb48c9 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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; diff --git a/includes/Wiki.php b/includes/Wiki.php index bf349cd8bb..4a2cb1039c 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -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