Skip to content

Instantly share code, notes, and snippets.

@intech
Forked from anonymous/.htaccess
Last active November 15, 2016 08:19
Show Gist options
  • Save intech/d8acc761c7df2e58c6e5cdecf3d79835 to your computer and use it in GitHub Desktop.
Save intech/d8acc761c7df2e58c6e5cdecf3d79835 to your computer and use it in GitHub Desktop.
Закрытие директории загрузки от исполнения
# Запрещаем листинг директории
Options -Indexes
# Здесь мы запрещаем доступ из веба к файлам с расширениями
<FilesMatch "\.(php|cgi|pl|php|php3|php4|php5|php6|php7|phps|phtml|shtml|py|phtml|pl|asp|aspx|cgi|dll|exe|ico|shtm|shtml|fcg|fcgi|fpl|asmx|pht|py|psp)$">
Order allow,deny
Deny from all
</FilesMatch>
# Ниже мы говорим, что данные расширения отдавать как текст, чтобы не выполнять как исполняемые файлы
# В данном случаи это уже не нужно, т.к. мы запретили доступ выше к данным файлам совсем из веба
<IfModule mod_mime.c>
RemoveHandler php .php3 .php4 .php5 .php6 .php7 .phtml .pl .asp .aspx .cgi .dll .exe .ico .shtm .shtml .fcg .fcgi .fpl .asmx .pht .py .psp
AddType text/plain php .php3 .php4 .php5 .php6 .php7 .phtml .pl .asp .aspx .cgi .dll .exe .ico .shtm .shtml .fcg .fcgi .fpl .asmx .pht .py .psp
</IfModule>
# Отключаем выполнение php скриптов для php5
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
# Отключаем выполнение php скриптов для php7
<IfModule mod_php7.c>
php_flag engine off
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment