Задание:
В файле .htaccess установить кодировку по умолчанию на UTF-8 и написать правила перенаправления на страницы ошибок:
401.html, 403.html, 404.html, 500.html
[spoiler title=»401.html»]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>401 Нет авторизации</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<style>
.notfound-401 {text-align: center;position: relative;top: 100px;}
.notfound-401 span {font-size: 1000%;display: block;line-height: 1;}
.notfound-401 i.fa {font-size: 1000%;}
.notfound-401 p {font-size: 300%; margin: 0; padding: 0;}
</style>
<body>
<div class="notfound-401">
<i class="fa fa-paper-plane-o"></i>
<span>401</span>
<p>Нет авторизации.</p>
</div>
</body>
</html>
[/spoiler]
[spoiler title=»403.html»]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>403 Запрещено!</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<style>
.notfound-403 {text-align: center;position: relative;top: 100px;}
.notfound-403 span {font-size: 1000%;display: block;line-height: 1;}
.notfound-403 i.fa {font-size: 1000%;}
.notfound-403 p {font-size: 300%; margin: 0; padding: 0;}
</style>
<body>
<div class="notfound-403">
<i class="fa fa-paper-plane-o"></i>
<span>403</span>
<p>Запрещено!.</p>
</div>
</body>
</html>
[/spoiler]
[spoiler title=»404.html»]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>404 Страница не найдена</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<style>
.notfound-404 {text-align: center;position: relative;top: 100px;}
.notfound-404 span {font-size: 1000%;display: block;line-height: 1;}
.notfound-404 i.fa {font-size: 1000%;}
.notfound-404 p {font-size: 300%; margin: 0; padding: 0;}
</style>
<body>
<div class="notfound-404">
<i class="fa fa-paper-plane-o"></i>
<span>404</span>
<p>Страница не найдена.</p>
</div>
</body>
</html>
[/spoiler]
[spoiler title=»500.html»]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>500 Ошибка сервера</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<style>
.notfound-500 {text-align: center;position: relative;top: 100px;}
.notfound-500 span {font-size: 1000%;display: block;line-height: 1;}
.notfound-500 i.fa {font-size: 1000%;}
.notfound-500 p {font-size: 300%; margin: 0; padding: 0;}
</style>
<body>
<div class="notfound-500">
<i class="fa fa-paper-plane-o"></i>
<span>500</span>
<p>Ошибка сервера.</p>
</div>
</body>
</html>
[/spoiler]
С помощью глобального массива $_SERVER вывести Имя хоста, IP сервера, Дирректория, Браузер.
[spoiler title=»Решение»]
AddDefaultCharset UTF-8 ErrorDocument 401 /401.html ErrorDocument 403 /403.html ErrorDocument 404 /404.html ErrorDocument 500 /500.html
<? echo "<br>Имя хоста: " .$_SERVER['SERVER_NAME']. "<br>IP Сервера: " .$_SERVER['SERVER_ADDR']. "<br>Дирректория: " .$_SERVER['DOCUMENT_ROOT']. "<br>Ваш браузер: " .$_SERVER['HTTP_USER_AGENT']."<br>"; ?>
[/spoiler]