From d6e3ad2806776e60648ca59780cc4e48daf603fe Mon Sep 17 00:00:00 2001 From: ebakernz Date: Mon, 21 Oct 2024 15:07:42 +1300 Subject: [PATCH] fix robots url (#36) --- src/Controller/RobotsTxtController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Controller/RobotsTxtController.php b/src/Controller/RobotsTxtController.php index cded54b..4542495 100644 --- a/src/Controller/RobotsTxtController.php +++ b/src/Controller/RobotsTxtController.php @@ -47,8 +47,15 @@ public function index(HTTPRequest $request) 'Host' => Director::absoluteBaseUrl() ])->renderWith('RobotsTxtDisallowAll'); } + + // Check base URL for trailing slash, add so filepath for robots.txt is correct + $baseURL = Director::absoluteBaseUrl(); + if(strrev($baseURL)[0] != '/') { + $baseURL .= '/'; + } + return $this->customise([ - 'Host' => Director::absoluteBaseUrl() + 'Host' => $baseURL ])->renderWith('RobotsTxt'); } }