r84820 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84819‎ | r84820 | r84821 >
Date:21:06, 26 March 2011
Author:bawolff
Status:ok (Comments)
Tags:
Comment:
(bug 28242) Make url's of the form http://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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Wiki.php
@@ -192,7 +192,8 @@
193193 }
194194 /* Check for a redirect loop */
195195 if( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
196 - $output->redirect( $url );
 196+ // 301 so google et al report the target as the actual url.
 197+ $output->redirect( $url, 301 );
197198 } else {
198199 $title = SpecialPage::getTitleFor( 'Badtitle' );
199200 $output->setTitle( $title ); // bug 21456
Index: trunk/phase3/includes/DefaultSettings.php
@@ -5320,7 +5320,9 @@
53215321
53225322 /**
53235323 * Disable redirects to special pages and interwiki redirects, which use a 302
5324 - * and have no "redirected from" link.
 5324+ * and have no "redirected from" link. Note this is only for articles with #Redirect
 5325+ * in them. URL's containing a local interwiki prefix (or a non-canonical special
 5326+ * page name) are still hard redirected regardless of this setting.
53255327 */
53265328 $wgDisableHardRedirects = false;
53275329
Index: trunk/phase3/RELEASE-NOTES
@@ -203,6 +203,8 @@
204204 page restrictions
205205 * Make truncate function automatically consider length of '...' string,
206206 since length can vary by localization.
 207+* (bug 28242) Make redirects generated by urls containing a local interwiki
 208+ prefix be a 301 instead of a 302.
207209
208210 === API changes in 1.18 ===
209211 * (bug 26339) Throw warning when truncating an overlarge API result

Follow-up revisions

RevisionCommit summaryAuthorDate
r852561.17wmf1: MFT r80813, r80815, r83798, r84459, r84729, r84820, r84921, r84985,...catrope14:13, 3 April 2011
r85435MFT: r84431, r84464, r84543, r84553, r84573, r84574, r84577, r84729, r84765, ...demon14:00, 5 April 2011

Comments

#Comment by He7d3r (talk | contribs)   21:38, 26 March 2011

Just for curiosity: what is (or should be) the behavior of search engines when the target page is disallowed in the robots.txt of the target wiki? Specifically, taking your example, in order to avoid w:Somewhere on pedia of being indexed, is it necessary to add the page to robots.txt of both Wikipedia and MediaWiki.org?

#Comment by Bawolff (talk | contribs)   21:58, 26 March 2011

I would assume that only the target of the redirect (Aka in the example, the page on Wikipedia) would have to be dis-allowed in robots.txt.

#Comment by MarkAHershberger (talk | contribs)   22:59, 29 March 2011

Marking this for 1.17, just in case we can still get it merged.

#Comment by He7d3r (talk | contribs)   23:08, 29 March 2011

Did you forget the tag?

#Comment by MarkAHershberger (talk | contribs)   23:26, 29 March 2011

head-to-desk. Yes.

#Comment by Krinkle (talk | contribs)   23:15, 29 March 2011

This also fixes http://en.wikipedia.org/wiki/Commons:Main_Page being the top result for 'wikimedia commons' in certain geolocation/browser combinations in Google.

(.. which is a redirect to http://commons.wikimedia.org/wiki/Main_Page )

#Comment by Bawolff (talk | contribs)   23:25, 29 March 2011

Well one hopes anyways. Alas I don't have a copy of google installed on my local computer ;). But the info out there suggests it will.

tagging this 1.17wmf1 - Presumably it should be tagged as either both, or neither (?)

#Comment by Krinkle (talk | contribs)   23:16, 29 March 2011

example: http://www.google.nl/search?rls=en&hl=nl&q=wikimedia+commons

1. Wikimedia Commons - [ Translate this page ]
	If you are browsing Commons for the first time, you may want to start with ...
	Category:Pictures and images - Photographs - Nature - Featured pictures
en.wikipedia.org/wiki/Commons:Main_Page - In cache

2. Hoofdpagina - Wikimedia Commons
	Indien u hier voor de eerste keer komt, bekijk dan vooral de Etalage ...
en.wikipedia.org/wiki/Commons:Hoofdpagina - In cache

Status & tagging log