了解htaccess Filesmatch代码 [英] Understanding htaccess Filesmatch code

查看:578
本文介绍了了解htaccess Filesmatch代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是一个巨大的痛苦


$ b $

我正在尝试在我的bluehost托管网站上的一个子目录中安装drupal b

我正在考虑.htaccess中的以下几行是问题。当我目前导航到mysite.com/subdir/install.php我得到一个403错误。但是,当我从下面的行中删除否认时,我停止得到这个错误,所以我怀疑这一行导致了所有的麻烦。



我的问题是,有人可以帮助我了解以下代码中发生了什么吗?特别是如果你可以按组件分解它。

 < FilesMatch\。(engine | inc | info | install | make | module | profile | test | po | SH | *。SQL |主题| TPL(\.php)|?xtmpl)(|〜| \.sw [OP] | \.bak | \.orig | \.save)$ |?^ (\ .. * |作品。* |库|根|标签|模板)$ | ^#*#$ | \.php(〜| \.sw [OP] | \.bak | \ .orig\.save)$> 
订单允许,拒绝
< / FilesMatch>


解决方案

FilesMatch 允许您使用正则表达式匹配文件。



在上述 FilesMatch 中,您有4套正则表达式,其中1个集合具有辅助可选集。



基本上它正在做的是禁止访问(错误403)到您在一组正则表达式。



例如:

  \。 engine | inc ...)$ | 

如果文件以.engine或.inc或...其余的规则结尾,则表示拒绝访问它。



然后在第一套规则结束时,您有一个 | ,如上所述例如,代表 OR ,所以如果第一组规则不匹配,则启动第二个规则,这是稍微不同的。

  ^(\ .. * | Entries。* | Repository)$ 

这样做恰恰相反,如果文件以一个给定的关键字开始和结束,它就会匹配,例如:



如果文件以后跟任何东西(。* )意味着其他任何东西,例如 .htaccess 或从条目开始后跟任何东西,或者完全是Repository或...直到结束。



然后下一个规则 ^#。*#$ ,这意味着文件开始和结束一个作为其处理字面上



和th最后一套规则的执行方式与第一个验证文件是否相同,如果文件以那些给定的扩展名结尾。



如果您想了解更多,那么我建议您更多地了解< a href =http://en.wikipedia.org/wiki/PCRE> Perl兼容的正则表达式(PCRE)


I am trying to install drupal in a subdirectory on my bluehost hosted website...

It's a HUGE pain

I'm thinking the following lines from the .htaccess is the problem. When I currently navigatoe to mysite.com/subdir/install.php I get a 403 error. However, when I take out "deny" from the lines below, I cease to get that error, so I suspect that this line is causing all the trouble.

My question is, can someone help me understand what is happening in the following code? Especially if you can break it down by component.

<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(|~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
      Order allow,deny
    </FilesMatch>

解决方案

FilesMatch allows you to match files using a regular expression.

On your above FilesMatch you have 4 sets of regular expression where the 1 set have an secondary optional set.

Basically what it is doing is forbidden access (error 403) to any of the files found that are described on your sets of regex.

For example:

\.(engine|inc ...)$|

Means if the file ends with .engine or .inc or ... rest of the rule, deny access to it.

Then at the end of the first set of rules you have a | which like the above example, stands for OR so if the first set of rules were not match, it starts the second one, which is slight different.

^(\..*|Entries.*|Repository)$

Here it does the opposite, it matches if the file starts and end with a given keyword, so for example:

If file starts with . followed by anything the (.*) means anything else for example .htaccess or starts with Entries followed by anything or is exactly Repository or ... till the end.

Then the next rule ^#.*#$, this one means the file starts and ends with a # as # its treated literally

And the last set of rules does the same of the first verify if file ends with those given extensions.

If you want to know more then I suggest you to learn more about Perl Compatible Regular Expressions (PCRE)

这篇关于了解htaccess Filesmatch代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆