From 34b7980587df61ae084bddd4513a45f6218467cd Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sat, 9 Jul 2022 20:23:29 +0300 Subject: use 302 redirects by default, explicitely specify 301 where really needed --- engine/RedirectResponse.php | 5 ++--- handler/Auto.php | 2 +- handler/ProjectsHtml.php | 2 +- lib/admin.php | 2 -- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/engine/RedirectResponse.php b/engine/RedirectResponse.php index 7900229..4526c6c 100644 --- a/engine/RedirectResponse.php +++ b/engine/RedirectResponse.php @@ -2,9 +2,8 @@ class RedirectResponse extends Response { - public function __construct(string $url) { - parent::__construct(301); - $this->addHeader('HTTP/1.1 301 Moved Permanently'); + public function __construct(string $url, int $code = 302) { + parent::__construct($code); $this->addHeader('Location: '.$url); } diff --git a/handler/Auto.php b/handler/Auto.php index c0d4c13..9903993 100644 --- a/handler/Auto.php +++ b/handler/Auto.php @@ -17,7 +17,7 @@ class Auto extends RequestHandler { public function get(): Response { list($name) = $this->input('name'); if ($name == 'coreboot-mba51-flashing') - return new RedirectResponse('/coreboot-mba52-flashing/'); + return new RedirectResponse('/coreboot-mba52-flashing/', 301); if (is_numeric($name)) { $post = posts::get((int)$name); diff --git a/handler/ProjectsHtml.php b/handler/ProjectsHtml.php index beada44..0c1dcbb 100644 --- a/handler/ProjectsHtml.php +++ b/handler/ProjectsHtml.php @@ -5,7 +5,7 @@ namespace handler\main; class ProjectsHtml extends \RequestHandler { public function get(): \Response { - return new \RedirectResponse('/projects/'); + return new \RedirectResponse('/projects/', 301); } } \ No newline at end of file diff --git a/lib/admin.php b/lib/admin.php index 0f9d610..91aa620 100644 --- a/lib/admin.php +++ b/lib/admin.php @@ -52,6 +52,4 @@ class admin { ]); } - } - -- cgit v1.2.3