У меня есть куча файлов secure_xxxxxx.php. Есть ли способ использовать .htaccess для блокировки доступа ко всем файлам secure_ * php на основе IP?
РЕДАКТИРОВАТЬ: Я пробовал, но получаю 500 ошибок
<FilesMatch "^secure_.*\.php$">
order deny all
deny from all
allow from my ip here
</FilesMatch>
Не вижу ошибок в журналах ошибок apache.
httpd -M
Loaded Modules:
core_module (static)
authn_file_module (static)
authn_default_module (static)
authz_host_module (static)
authz_groupfile_module (static)
authz_user_module (static)
authz_default_module (static)
auth_basic_module (static)
include_module (static)
filter_module (static)
log_config_module (static)
logio_module (static)
env_module (static)
expires_module (static)
headers_module (static)
setenvif_module (static)
version_module (static)
proxy_module (static)
proxy_connect_module (static)
proxy_ftp_module (static)
proxy_http_module (static)
proxy_scgi_module (static)
proxy_ajp_module (static)
proxy_balancer_module (static)
ssl_module (static)
mpm_prefork_module (static)
http_module (static)
mime_module (static)
dav_module (static)
status_module (static)
autoindex_module (static)
asis_module (static)
info_module (static)
suexec_module (static)
cgi_module (static)
dav_fs_module (static)
negotiation_module (static)
dir_module (static)
actions_module (static)
userdir_module (static)
alias_module (static)
rewrite_module (static)
so_module (static)
fastinclude_module (shared)
auth_passthrough_module (shared)
bwlimited_module (shared)
frontpage_module (shared)
suphp_module (shared)
Syntax OK
Файлы вроде работают нормально.
Вы должны иметь возможность использовать директиву Files и mod_authz_host для достижения своих целей.
Например:
<Files "secure_*.php">
Require 192.168.0.0/24
</Files>
См. Ссылки ниже.
http://httpd.apache.org/docs/current/mod/core.html#files http://httpd.apache.org/docs/current/howto/access.html
Или используя FilesMatch и старый синтаксис ACL:
<FilesMatch "^secure_.*\.php$">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</FilesMatch>
Это должно разрешать доступ только с localhost.
Да, я думаю, что это возможно, используя регулярное выражение в .htaccess http://expressionengine.com/wiki/Regular_Expressions_in_.htaccess
а также ограничение на основе IP-адресов, использующих allow
и deny
параметры.