的.htaccess拒绝所有,除?

编程入门 行业动态 更新时间:2024-10-24 12:28:18
本文介绍了的.htaccess拒绝所有,除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这样的htaccess的规则来阻止所有的.xml请求:

I have this htaccess rule to block all .xml requests:

<Files ~ "\.xml$"> Order allow,deny Deny from all Satisfy all </Files>

不过,我需要允许一个特定的.xml文件。应如何规则重新写的?

However, I need to allow one certain .xml file. How should the rule be re-written?

此外,上述这条规则,我有这样一个例外:

Also, above that rule, I have an exception like this:

RewriteRule ^(myxml\.xml)$ $1 [L]

但是,这仍然不允许该文件

But that still doesn't allow the file.

推荐答案

Apache的正则表达式引擎是PCRE兼容,所以为什么不使用正则表达式为负向后断言(小于?!\ bmyxml) \的.xml $?

The Apache Regexp Engine is PCRE compatible so why not use a regexp with a negative lookbehind assertion "(?<!\bmyxml)\.xml$"?

它说的是比赛的东西以.xml结束,只要它不是通过与myXML pceded $ P $。这意味着,该规则将不会触发myxml.xml,这样就不会被拒绝。

What this says is match something ending in .xml so long as it's not preceded by myxml. This means that the rule won't fire for myxml.xml, so it won't be denied.

BTW FilesMatch是根据Apache的文档〜pferred到文件$ P $。不要问我为什么。

BTW FilesMatch is preferred to Files ~ according to the Apache docs. Don't ask me why.

更多推荐

的.htaccess拒绝所有,除?

本文发布于:2023-10-31 12:53:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546141.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!