-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
header.php
78 lines (61 loc) · 1.88 KB
/
header.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
if (!isset($_SERVER['HTTPS'])) {
header('HTTP/1.1 301 Moved Permanently');
header(
'Location: https://www.nodebeginner.org'
. $_SERVER['REQUEST_URI']
);
die();
}
if ($_SERVER['HTTP_HOST'] == 'nodebeginner.org') {
header('HTTP/1.1 301 Moved Permanently');
header(
'Location: https://www.nodebeginner.org'
. $_SERVER['REQUEST_URI']
);
die();
}
if ( $_SERVER['REQUEST_URI'] === '/blog/post/'
|| $_SERVER['REQUEST_URI'] === '/blog/post'
|| $_SERVER['REQUEST_URI'] === '/blog/post/index.html')
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.nodebeginner.org/blog/');
die();
}
if ( $_SERVER['REQUEST_URI'] === '/web-development-beginner-tutorial/post/'
|| $_SERVER['REQUEST_URI'] === '/web-development-beginner-tutorial/post'
|| $_SERVER['REQUEST_URI'] === '/web-development-beginner-tutorial/post/index.html')
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.nodebeginner.org/web-development-beginner-tutorial/');
die();
}
ob_start();
$httpHost = $_SERVER['HTTP_HOST'];
$requestUri = $_SERVER['REQUEST_URI'];
$queryString = $_SERVER['QUERY_STRING'];
$pathinfo = pathinfo($_ENV['SCRIPT_FILENAME']);
$extension = $pathinfo['extension'];
if ($extension != 'html') {
header('Expires: ' . gmdate('D, d M Y H:i:s T', time() + 604800)); // 1 week
}
if ($extension == 'html') {
header('Content-type: text/html; charset=utf-8');
}
if ($extension == 'css') {
header('Content-type: text/css; charset=utf-8');
}
if ($extension == 'js') {
header('Content-type: text/javascript; charset=utf-8');
}
if ($extension == 'png') {
header('Content-type: image/png');
}
if ($extension == 'jpg') {
header('Content-type: image/jpeg');
}
if ($extension == 'gif') {
header('Content-type: image/gif');
}
header('X-Went-Through-Header-File: yes');