fix(seo): support direct robots.txt and sitemap.xml routing in HomeController
This commit is contained in:
parent
d104408da9
commit
275321f28b
1 changed files with 10 additions and 0 deletions
|
|
@ -3,6 +3,16 @@ require_once __DIR__ . '/../../core/Controller.php';
|
||||||
class HomeController extends Controller {
|
class HomeController extends Controller {
|
||||||
// Main Route Handler
|
// Main Route Handler
|
||||||
public function index($name = 'home') {
|
public function index($name = 'home') {
|
||||||
|
if ($name === 'robots.txt') {
|
||||||
|
require_once __DIR__ . '/SeoController.php';
|
||||||
|
$seo = new SeoController();
|
||||||
|
return $seo->robots();
|
||||||
|
}
|
||||||
|
if ($name === 'sitemap.xml') {
|
||||||
|
require_once __DIR__ . '/SeoController.php';
|
||||||
|
$seo = new SeoController();
|
||||||
|
return $seo->sitemap();
|
||||||
|
}
|
||||||
$routeName = str_replace(['.xml', '.txt'], '', $name);
|
$routeName = str_replace(['.xml', '.txt'], '', $name);
|
||||||
$allowedRoutes = ['about', 'imprint', 'privacy'];
|
$allowedRoutes = ['about', 'imprint', 'privacy'];
|
||||||
if (in_array($routeName, $allowedRoutes)) {
|
if (in_array($routeName, $allowedRoutes)) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue