* namespace, show the default message text. To be called from Article::view().
*/
public function showMissingArticle() {
- global $wgOut, $wgRequest, $wgUser;
+ global $wgOut, $wgRequest, $wgUser, $wgSend404Code;
# Show info in user (talk) namespace. Does the user exist? Is he blocked?
if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) {
}
$text = "<div class='noarticletext'>\n$text\n</div>";
- if ( !$this->mPage->hasViewableContent() ) {
+ if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
// If there's no backing content, send a 404 Not Found
// for better machine handling of broken links.
$wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
*/
$wgBetterDirectionality = true;
+/**
+ * Some web hosts attempt to rewrite all responses with a 404 (not found)
+ * status code, mangling or hiding MediaWiki's output. If you are using such a
+ * host, you should start looking for a better one. While you're doing that,
+ * set this to false to convert some of MediaWiki's 404 responses to 200 so
+ * that the generated error pages can be seen.
+ *
+ * In cases where for technical reasons it is more important for MediaWiki to
+ * send the correct status code than for the body to be transmitted intact,
+ * this configuration variable is ignored.
+ */
+$wgSend404Code = true;
/** @} */ # End of output format settings }
protected function openShowImage() {
global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
- $wgLang, $wgEnableUploads;
+ $wgLang, $wgEnableUploads, $wgSend404Code;
$this->loadFile();
// by Article::View().
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
- if ( !$this->getID() ) {
+ if ( !$this->getID() && $wgSend404Code ) {
// If there is no image, no shared image, and no description page,
// output a 404, to be consistent with articles.
$wgRequest->response()->header( 'HTTP/1.1 404 Not Found' );
if ( !$page ) {
$context->getOutput()->setArticleRelated( false );
$context->getOutput()->setRobotPolicy( 'noindex,nofollow' );
- $context->getOutput()->setStatusCode( 404 );
+
+ global $wgSend404Code;
+ if ( $wgSend404Code ) {
+ $context->getOutput()->setStatusCode( 404 );
+ }
+
$context->getOutput()->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
wfProfileOut( __METHOD__ );
return false;