-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
36 lines (34 loc) · 929 Bytes
/
index.php
File metadata and controls
36 lines (34 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* Secure Redirect
*
* Detects and redirects HTTP connections to HTTPS
*
* php version 7
*
* @category Pages
* @package BoardgamesAPI
* @subpackage Core
* @author John Beech <[email protected]>
* @license https://choosealicense.com/licenses/isc/ ISC
* @link https://boardgames-api.calisaurus.net/
*/
if (!isset($_SERVER['HTTPS'])) {
$url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
exit("Redirecting to secure endpoint: $url");
} else {
$url = '/docs/';
header("Location: $url");
exit(
join(
'\n', array(
'<!DOCTYPE html>',
'<html>',
'<head><title>Redirecting to Board Game API /docs/</title></head>',
'<body><script type="text/javascript">window.location = "'
. $url . '"</script></body>',
'</html>')
)
);
}