LocationMatch否定表达

时间:2015-10-14 14:53:02

标签: regex apache apache-config locationmatch

我想为网站提供密码保护,只需保留网络服务网址即可。

这个表达式在apache中完美运行,只需转向对面。

[button setImage: img forState: UIControlStateSelected | UIControlStateHighlighted];
[button setImage: img forState: UIControlStateSelected];
[button setImage: img forState: UIControlStateHighlighted];

我尝试了许多形式,但不起作用。 我试过这个并且在调节器测试器中完美地工作,而不是在apache(2.2)

<LocationMatch "^(.*service).*$">
        AuthType Basic
        AuthName "Restricted Files"
        AuthUserFile /storage/www/xxxxx/.htpasswd
        Require valid-user
</LocationMatch>

如何否定这种表达?

.htaccess内容如果有问题。

<LocationMatch "^(?!.*service).*$">

1 个答案:

答案 0 :(得分:0)

似乎Apache regexp支持太有限了。

但是,您可以通过在封闭子句中定义所需的所有内容(例如,“位置”),然后在您的(非否定的)LocationMatch下恢复为“默认”设置,轻松地“否定”您的表达。 / p>

像这样:https://serverfault.com/questions/591591/apache-locationmatch-regex-behaviour-does-not-seem-correct