From 119f9f48b6ba1a43e85f1775510887d57d6807ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=88=E7=9F=A2=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Thu, 19 Mar 2026 04:24:24 +0900 Subject: [PATCH] =?UTF-8?q?robots.txt=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route.php | 1 + src/Site/Controller/Home.php | 9 +++++++++ 2 files changed, 10 insertions(+) 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); + } + //------------------------------------------ // 機能性 //------------------------------------------