function addHeader( $name, $val ) { array_push( $this->mHeaders, "$name: $val" ) ; }
function addCookie( $name, $val ) { array_push( $this->mCookies, array( $name, $val ) ); }
- function redirect( $url ) { $this->mRedirect = $url; }
+ function redirect( $url, $responsecode = '302' ) { $this->mRedirect = $url; $this->mRedirectCode = $responsecode; }
# To add an http-equiv meta tag, precede the name with "http:"
function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
$sk = $wgUser->getSkin();
- $this->sendCacheControl();
-
- header( "Content-type: text/html; charset={$wgOutputEncoding}" );
- header( "Content-language: {$wgLanguageCode}" );
if ( "" != $this->mRedirect ) {
if( substr( $this->mRedirect, 0, 4 ) != "http" ) {
global $wgServer;
$this->mRedirect = $wgServer . $this->mRedirect;
}
+ if( $this->mRdirectCode != '302') {
+ header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
+ $this->mLastModified = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix(
+ max( $timestamp, $wgUser->mTouched ) ) ) . " GMT";
+ }
+
+ $this->sendCacheControl();
+
header( "Location: {$this->mRedirect}" );
return;
}
+
+ $this->sendCacheControl();
+
+ header( "Content-type: text/html; charset={$wgOutputEncoding}" );
+ header( "Content-language: {$wgLanguageCode}" );
$exp = time() + $wgCookieExpiration;
foreach( $this->mCookies as $name => $val ) {
$wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
$wgOut->errorpage( "badtitle", "badtitletext" );
} else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
- /* redirect to canonical url */
- $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ) );
+ /* redirect to canonical url, make it a 301 to allow caching */
+ $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ), '301');
} else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
wfSpecialPage();
} else {