.htaccess文件名可能被阻止?

我有一堆secure_xxxxxx.php文件。 有没有办法使用.htaccess阻止访问基于IP的所有secure_ * php文件?

编辑:我试过,但我得到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> 

这应该只允许从本地主机访问。

是的,我认为可以通过使用.htaccess中的正则expression式http://expressionengine.com/wiki/Regular_Expressions_in_.htaccess

还有基于IP使用allowdeny选项的限制。