Added mod_rewrite for nginx module
This commit is contained in:
0
cms/simple/subdir/.gitkeep
Normal file
0
cms/simple/subdir/.gitkeep
Normal file
30
cms/simple/subdir/.htaccess
Normal file
30
cms/simple/subdir/.htaccess
Normal file
@@ -0,0 +1,30 @@
|
||||
# ============================================================
|
||||
# .htaccess в подкаталоге subdir - Тесты mod_rewrite для nginx
|
||||
# ============================================================
|
||||
# Этот файл проверяет работу правил для конкретного location (подкаталога)
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Правило 1: Все запросы к файлам с расширением xmx в этом подкаталоге
|
||||
# должны блокироваться с ошибкой 403 Forbidden
|
||||
|
||||
RewriteRule \.xmx$ - [F,L]
|
||||
|
||||
# Тестирование:
|
||||
# - http://localhost/test/subdir/other.xmx → 403 Forbidden
|
||||
|
||||
# Правило 2: Внутреннее перенаделение subdir/file.html на ../show.html
|
||||
# (переход из подкаталога в родительский)
|
||||
|
||||
RewriteRule ^file\.html$ ../show.html [L]
|
||||
|
||||
# Тестирование:
|
||||
# - http://localhost/test/subdir/file.html → показывает содержимое show.html
|
||||
|
||||
# Правило 3: Блокировка доступа ко всем файлам кроме .html
|
||||
|
||||
RewriteCond %{REQUEST_URI} !\.html$
|
||||
RewriteRule ^ - [F,L]
|
||||
|
||||
# Тестирование:
|
||||
# - http://localhost/test/subdir/file.txt → 403 Forbidden
|
||||
26
cms/simple/subdir/file.html
Normal file
26
cms/simple/subdir/file.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>File - Тест mod_rewrite для nginx</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>file.html</h1>
|
||||
<p>Вы попали на file.html в подкаталоге subdir.</p>
|
||||
|
||||
<hr />
|
||||
<ul>
|
||||
<li><a href="../index.html">На главную (index.html)</a></li>
|
||||
<li><a href="../show.html">Показать (show.html)</a></li>
|
||||
<li><a href="../redirect.html">Redirect</a></li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<p>
|
||||
<em><strong style="color: green;">Это страница из подкаталога!</strong></em>
|
||||
</p>
|
||||
<p>
|
||||
При обращении к <code>/test/subdir/file.html</code>, mod_rewrite должен показать содержимое <code>../show.html</code>.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
27
cms/simple/subdir/other.xmx
Normal file
27
cms/simple/subdir/other.xmx
Normal file
@@ -0,0 +1,27 @@
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Other XMX - Тест mod_rewrite для nginx</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>other.xmx</h1>
|
||||
<p>Вы попытались получить этот файл.</p>
|
||||
|
||||
<hr />
|
||||
<ul>
|
||||
<li><a href="../index.html">На главную (index.html)</a></li>
|
||||
<li><a href="../show.html">Показать (show.html)</a></li>
|
||||
<li><a href="file.html">File.html</a></li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
<p>
|
||||
<em><strong style="color: red;">Этот файл должен быть заблокирован!</strong></em>
|
||||
</p>
|
||||
<p>
|
||||
При обращении к <code>/test/subdir/other.xmx</code>, mod_rewrite должен вернуть
|
||||
<code style="background-color: #f00; color: white;">403 Forbidden</code>.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user