Browse Source

Add robots.txt

master
Riyyi 4 years ago
parent
commit
b1072b360e
  1. 16
      app/controllers/IndexController.php
  2. 1
      route.php

16
app/controllers/IndexController.php

@ -68,6 +68,20 @@ class IndexController extends PageController {
exit();
}
public function robotsAction(): void
{
$url = Config::c('APP_URL');
header('content-type: text/plain; charset=UTF-8');
echo <<< EOF
User-agent: *
Allow: /
Disallow: /admin
Sitemap: $url/sitemap.xml
EOF;
}
public function sitemapAction(): void
{
$xml = new \SimpleXMLElement('<urlset/>');
@ -91,7 +105,7 @@ class IndexController extends PageController {
$url->addChild('loc', $loc);
}
Header('Content-type: text/xml');
header('content-type: text/xml; charset=UTF-8');
print($xml->asXML());
}

1
route.php

@ -14,6 +14,7 @@ return [
// URL, controller, action, view/title/description
['/', 'IndexController', '', ''],
['/img/captcha.jpg', 'IndexController', 'captcha', ''],
['/robots.txt', 'IndexController', 'robots', ''],
['/sitemap.xml', 'IndexController', 'sitemap', ''],
['/login', 'LoginController', 'login', ['', 'Sign in', '']],
['/reset-password', 'LoginController', 'reset', ['', 'Reset password', '']],

Loading…
Cancel
Save