Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion modules/mediawiki/files/robots.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use MediaWiki\Content\TextContent;
use MediaWiki\MediaWikiServices;
use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Title\Title;

$page = MediaWikiServices::getInstance()
Expand Down Expand Up @@ -38,7 +39,26 @@
$lastmod = gmdate( 'D, j M Y H:i:s', $mtime ) . ' GMT';
header( "Last-modified: $lastmod" );

fpassthru( $robots );
if ( php_uname( 'n' ) === 'test151' ) {
$specialPagePath = SpecialPage::getTitleFor( 'Badtitle' )->getLocalURL();
$specialPrefix = substr( $specialPagePath, 0, strpos( $specialPagePath, 'Badtitle' ) );
while ( ( $line = fgets( $robots ) ) !== false ) {
if ( strpos( $line, 'REPLACEME' ) !== false ) {
echo "Disallow: $specialPrefix\n";
// Handle the other URL pattern in case article root changes
if ( str_starts_with( $line, '/wiki/' ) ) {
$newPrefix = str_replace( '/wiki/', '/', $line );
} else {
$newPrefix = '/wiki' . $line;
}
echo "Disallow: $newPrefix\n";
} else {
echo $line;
}
}
} else {
fpassthru( $robots );
}

echo "#\n#\n#----------------------------------------------------------#\n#\n#\n#\n";
# Dynamic sitemap url
Expand Down
Loading