diff --git a/route.php b/route.php index 03fd991..2f5140c 100644 --- a/route.php +++ b/route.php @@ -21,6 +21,7 @@ if (DEBUG_MODE) { include(ROOT.'/util.php'); $routes = [ + Route::add('GET', 'robots.txt', Home::class.'@robots'), Route::add('GET', 'blog/{page}', Home::class.'@article'), Route::add('GET', 'about', Page::class.'@about'), Route::add('GET', 'monero', Page::class.'@monero'), diff --git a/src/Site/Controller/Home.php b/src/Site/Controller/Home.php index ac3b057..0ea4af1 100644 --- a/src/Site/Controller/Home.php +++ b/src/Site/Controller/Home.php @@ -157,6 +157,15 @@ denyaccess: } } + public function robots(array $params): void { + $txt = "User-Agent: *\nDisallow: /login/\nDisallow: /register/"; + $tmpFile = tempnam(sys_get_temp_dir(), 'tmpl_'); + file_put_contents($tmpFile, $txt); + + include $tmpFile; + unlink($tmpFile); + } + //------------------------------------------ // 機能性 //------------------------------------------