AntCMS/src/Plugins/Robotstxt/RobotstxtPlugin.php
Belle Aerni 91395db9c4 Added robots.txt plugin
Automatically generates the content, including the correct link to the sitemap.
2023-01-14 00:30:29 -08:00

26 lines
675 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.= 'Sitemap: ' . $protocol . '://' . AntTools::repairURL($baseURL . '/sitemap.xml' . "\n");
header("Content-Type: text/plain");
echo $robotstxt;
exit;
}
public function getName()
{
return 'Robotstxt';
}
}