From 91395db9c4d9e12e1e5707300d37a2db7bd64368 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Sat, 14 Jan 2023 00:30:29 -0800 Subject: [PATCH] Added robots.txt plugin Automatically generates the content, including the correct link to the sitemap. --- configs/nginx.conf | 10 --------- src/.htaccess | 3 --- src/Plugins/Robotstxt/RobotstxtPlugin.php | 25 +++++++++++++++++++++++ src/index.php | 7 ++++++- src/robots.txt | 2 -- 5 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 src/Plugins/Robotstxt/RobotstxtPlugin.php delete mode 100644 src/robots.txt diff --git a/configs/nginx.conf b/configs/nginx.conf index e64b0bb..87a1f79 100644 --- a/configs/nginx.conf +++ b/configs/nginx.conf @@ -5,16 +5,6 @@ location ~ ^/Themes/[^/]+/Assets/ { } } -location /robots.txt { - # Allow access to the robots.txt file - try_files $uri =204; -} - -location /sitemap.xml { - # Allow access to the sitemap.xml file - try_files $uri =204; -} - location / { try_files $uri $uri/ /index.php?$args; } diff --git a/src/.htaccess b/src/.htaccess index 470f73e..d48a70a 100644 --- a/src/.htaccess +++ b/src/.htaccess @@ -5,7 +5,4 @@ CGIPassAuth On RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^Themes/[^/]+/Assets/.+$ - [L] -# Allow access to the robots.txt file -RewriteRule ^robots\.txt$ - [L] - RewriteRule ^(.+)$ index.php [L,QSA] diff --git a/src/Plugins/Robotstxt/RobotstxtPlugin.php b/src/Plugins/Robotstxt/RobotstxtPlugin.php new file mode 100644 index 0000000..2bb95f7 --- /dev/null +++ b/src/Plugins/Robotstxt/RobotstxtPlugin.php @@ -0,0 +1,25 @@ +