robots.txtの追加
守矢諏訪子 <suwako@076.moe>、2026-03-19 04:24
コミット 119f9f48b6ba1a43e85f1775510887d57d6807ee
・親 a1bd29c
・ファイルを見る
2個のファイル、+10 -0
変更
route.php
| @@ -21,6 +21,7 @@ | ||
| 21 | 21 | include(ROOT.'/util.php'); |
| 22 | 22 | |
| 23 | 23 | $routes = [ |
| 24 | + Route::add('GET', 'robots.txt', Home::class.'@robots'), | |
| 24 | 25 | Route::add('GET', 'blog/{page}', Home::class.'@article'), |
| 25 | 26 | Route::add('GET', 'about', Page::class.'@about'), |
| 26 | 27 | Route::add('GET', 'monero', Page::class.'@monero'), |
| @@ -157,6 +157,15 @@ | ||
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | + public function robots(array $params): void { | |
| 161 | + $txt = "User-Agent: *\nDisallow: /login/\nDisallow: /register/"; | |
| 162 | + $tmpFile = tempnam(sys_get_temp_dir(), 'tmpl_'); | |
| 163 | + file_put_contents($tmpFile, $txt); | |
| 164 | + | |
| 165 | + include $tmpFile; | |
| 166 | + unlink($tmpFile); | |
| 167 | + } | |
| 168 | + | |
| 160 | 169 | //------------------------------------------ |
| 161 | 170 | // 機能性 |
| 162 | 171 | //------------------------------------------ |