From eb763d2dc2da197c2a42a9440e86dd632b7d177a Mon Sep 17 00:00:00 2001 From: raincoats Date: Sun, 5 Mar 2017 16:58:21 +1100 Subject: [PATCH 1/2] Redirect to admin panel when accessing 'http://pi.hole/' If someone tries to access 'http://pi.hole/', it will take them to the "Website blocked" page. Very confusing if you don't know to go to 'http://pi.hole/admin/'. This just redirects them to the admin panel. --- advanced/index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/advanced/index.php b/advanced/index.php index c076f92d..05b0811f 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -4,6 +4,14 @@ $uri = escapeshellcmd($_SERVER['REQUEST_URI']); $serverName = escapeshellcmd($_SERVER['SERVER_NAME']); +// If the server name is 'pi.hole', it's likely a user trying to get to the admin panel. +// Let's be nice and redirect them. +if ($serverName === 'pi.hole') +{ + header('HTTP/1.1 302 Found'); + header("Location: /admin/"); +} + // Retrieve server URI extension (EG: jpg, exe, php) $uriExt = pathinfo($uri, PATHINFO_EXTENSION); From 1590a179fa37fb8157f5a89639c776034322f13f Mon Sep 17 00:00:00 2001 From: raincoats Date: Thu, 9 Mar 2017 17:38:56 +1100 Subject: [PATCH 2/2] Change 302 redirect to 301 Change "302 Found" response to "301 Moved Permanently", as "302 Found" is meant for temporary redirects. Was asked to do so in this comment: https://github.com/pi-hole/pi-hole/pull/1297#issuecomment-284335421 --- advanced/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index 05b0811f..99f8c1f8 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -8,7 +8,7 @@ $serverName = escapeshellcmd($_SERVER['SERVER_NAME']); // Let's be nice and redirect them. if ($serverName === 'pi.hole') { - header('HTTP/1.1 302 Found'); + header('HTTP/1.1 301 Moved Permanently'); header("Location: /admin/"); }