AntCMS/src/Plugins/Robotstxt/RobotstxtPlugin.php
2023-05-13 13:08:33 -07:00

29 lines
788 B
PHP

<?php
use AntCMS\AntPlugin;
use AntCMS\AntConfig;
use AntCMS\AntTools;
class RobotstxtPlugin extends AntPlugin
{
public function handlePluginRoute(array $route)
{
$protocol = AntConfig::currentConfig('forceHTTPS') ? 'https' : 'http';
$baseURL = AntConfig::currentConfig('baseURL');
$robotstxt = 'User-agent: *' . "\n";
$robotstxt .= 'Disallow: /plugin/' . "\n";
$robotstxt .= 'Disallow: /admin/' . "\n";
$robotstxt .= 'Disallow: /profile/' . "\n";
$robotstxt .= 'Sitemap: ' . $protocol . '://' . AntTools::repairURL($baseURL . '/sitemap.xml' . "\n");
header("Content-Type: text/plain");
echo $robotstxt;
exit;
}
public function getName(): string
{
return 'Robotstxt';
}
}