【问题标题】:Exclude one file from password protection in .htaccess从 .htaccess 中的密码保护中排除一个文件
【发布时间】:2011-07-12 18:05:57
【问题描述】:

我有以下代码来保护.htaccess中的密码文件:

<FilesMatch "\.(html|htm|css|js|php|swf|swz|xml|ico|jpg|jpeg|png|txt)$">
AuthName "Member Only"
AuthType Basic
AuthUserFile /path/to/password/.htpasswd
require valid-user
</FilesMatch>

如何从此处排除should_be_excluded.php 不受密码保护? 如果需要,我可以更改保护线,但我认为可以在正则表达式中完成某些操作?

【问题讨论】:

    标签: php regex apache .htaccess


    【解决方案1】:

    怎么样:

    <FilesMatch "\.(html|htm|css|js|php|swf|swz|xml|ico|jpg|jpeg|png|txt)$">
        AuthName "Member Only"
        AuthType Basic
        AuthUserFile /path/to/password/.htpasswd
        require valid-user
    </FilesMatch>
    <Files /should_be_excluded.php>
        Order Allow,Deny
        Allow from all
    </Files>
    

    这应该允许ALL访问排除的文件吗?

    【讨论】:

    • 这不起作用,你试过吗?如果是,并且工作了您拥有的 apache 版本,您认为可能是什么问题?
    • @Centurion 尝试在Allow from all下方添加Satisfy all
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 1970-01-01
    • 2012-11-14
    • 2015-10-19
    • 2014-12-16
    • 2010-11-28
    相关资源
    最近更新 更多