use 302 redirects by default, explicitely specify 301 where really needed

This commit is contained in:
Evgeny Zinoviev 2022-07-09 20:23:29 +03:00
parent 8ea3807f4b
commit 34b7980587
4 changed files with 4 additions and 7 deletions

View File

@ -2,9 +2,8 @@
class RedirectResponse extends Response { class RedirectResponse extends Response {
public function __construct(string $url) { public function __construct(string $url, int $code = 302) {
parent::__construct(301); parent::__construct($code);
$this->addHeader('HTTP/1.1 301 Moved Permanently');
$this->addHeader('Location: '.$url); $this->addHeader('Location: '.$url);
} }

View File

@ -17,7 +17,7 @@ class Auto extends RequestHandler {
public function get(): Response { public function get(): Response {
list($name) = $this->input('name'); list($name) = $this->input('name');
if ($name == 'coreboot-mba51-flashing') if ($name == 'coreboot-mba51-flashing')
return new RedirectResponse('/coreboot-mba52-flashing/'); return new RedirectResponse('/coreboot-mba52-flashing/', 301);
if (is_numeric($name)) { if (is_numeric($name)) {
$post = posts::get((int)$name); $post = posts::get((int)$name);

View File

@ -5,7 +5,7 @@ namespace handler\main;
class ProjectsHtml extends \RequestHandler { class ProjectsHtml extends \RequestHandler {
public function get(): \Response { public function get(): \Response {
return new \RedirectResponse('/projects/'); return new \RedirectResponse('/projects/', 301);
} }
} }

View File

@ -52,6 +52,4 @@ class admin {
]); ]);
} }
} }