S
S
Shimpanze2018-08-29 05:33:23
Apache HTTP Server
Shimpanze, 2018-08-29 05:33:23

How to write such .htaccess?

It is necessary to:
1. prohibit viewing (listing?) all files in the folder and its subfolders;
2. deny access to all files in the folder (including .htaccess itself) except for the specified file1.txt, myfile.php, ... etc.,
3. how to register your error files, for example 404.php, 403.php etc. which are located in the folder error/?
So far I've concocted this, but nothing works:

# Запрещаем просмотр содержимого папки
Options All —Indexes

# Защищаем .htaccess файл
# вообще непонятно, надо ли защищать его отдельно от всех?
<files .htaccess="">
order allow,deny
deny from all
</files>

# Запрещаем доступ к папке и всем её подпапкам
Order Allow,Deny
Deny from all
# Теперь пишем исключения для нужных нам файлов
<FilesMatch "(\/error\/401\.php|\/error\/403\.php|\/error\/404\.php|\/error\/500\.php|file1\.txt|myfile\.php)$">
Order Deny,Allow
Allow from all
</FilesMatch>

# Делаем свои ошибки
ErrorDocument 401 /error/401.php
ErrorDocument 403 /error/403.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question