-} else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
- /* redirect to canonical url */
- $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ) );
+} else if ( $wgTitle->getInterwiki() != "" ) {
+ $url = $wgTitle->getFullURL();
+ # Check for a redirect loop
+ if ( !preg_match( "/^" . preg_quote( $wgServer, "/" ) . "/", $url ) && $wgTitle->isLocal() ) {
+ $wgOut->redirect( $url );
+ } else {
+ $wgTitle = Title::newFromText( wfMsgForContent( "badtitle" ) );
+ $wgOut->errorpage( "badtitle", "badtitletext" );
+ }
+} else if ( ( $action == "view" ) &&
+ (!isset( $_GET['title'] ) || $wgTitle->getPrefixedDBKey() != $_GET['title'] ) &&
+ !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
+{
+ /* redirect to canonical url, make it a 301 to allow caching */
+ $wgOut->redirect( $wgTitle->getFullURL(), '301');