了解htaccess的Filesmatch codehtaccess、Filesmatch、code

2023-09-02 11:27:31 作者:敷衍

我想在我的BlueHost的托管网站的Drupal安装在一个子目录...

这是一个巨大的痛苦。

我想以下行从的.htaccess的问题。当我现在navigatoe到mysite.com/subdir/install.php~~V我得到一个403错误。然而,当我拿出从下面的线拒绝,我不再得到这个错误,所以我怀疑这条线是造成所有的麻烦。

我的问题是,有人可以帮助我了解什么是发生在以下code?特别是如果你可以通过成分分解。

 < 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)$">
      订购允许,拒绝
    < / FilesMatch>
 

解决方案

FilesMatch 允许您使用的是常规的前pression相匹配的文件。

在你的上面 FilesMatch 你有4套普通EX pression其中1套有一个二次可选设置。

基本上它是做什么是禁止访问(错误403)的任何情况在您的正则表达式集合描述中的所有文件。

SpringBoot No configuration files matching pattern found并且add中无spring

例如:

  。(发动机| INC ...)$ |
 

意味着如果文件.ENGINE或。公司或结束......规则的休息,拒绝访问它。

然后在第一组规则的最后,你有一个 | 这就像上面的例子中,代表因此,如果所述第一组规则不匹配,它启动第二个,这是轻微不同

  ^( .. * |条目。* |库)$
 

这则正好相反,它如果文件开始匹配,并且与给定的关键字结束,因此,例如:

如果文件开头其次是任何东西(。* )指别的,例如的.htaccess 或任何开头条目其次或者是完全的信息库和......到最后。

那么下一条规则 ^#*#$ ,这个意味着该文件的起始和一个#为其字面上的处理

和最后一组规则做了同样的第一个验证文件与特定扩展名结尾。

如果您想了解更多的话,我建议你详细了解 Perl兼容普通防爆pressions(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)