Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess .ht403-如何修复此问题?_.htaccess - Fatal编程技术网

.htaccess .ht403-如何修复此问题?

.htaccess .ht403-如何修复此问题?,.htaccess,.htaccess,我有一个网站,我把phpbb3包装在wordpress中。虽然我在.htaccess中添加了此安全建议,但它运行得非常好: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK) [NC] RewriteRule ^(.*)$ - [F,L] RewriteCond %{QUERY_STRING} \.\.\/ [N

我有一个网站,我把phpbb3包装在wordpress中。虽然我在.htaccess中添加了此安全建议,但它运行得非常好:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK) [NC]
RewriteRule ^(.*)$ - [F,L]
RewriteCond %{QUERY_STRING} \.\.\/ [NC,OR]
RewriteCond %{QUERY_STRING} boot\.ini [NC,OR]
RewriteCond %{QUERY_STRING} tag\= [NC,OR]
RewriteCond %{QUERY_STRING} ftp\:  [NC,OR]
RewriteCond %{QUERY_STRING} http\:  [NC,OR]
RewriteCond %{QUERY_STRING} https\:  [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [NC,OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>|ê|"|;|\?|\*|=$).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(&#x22;|&#x27;|&#x3C;|&#x3E;|&#x5C;|&#x7B;|&#x7C;).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(%24&x).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(%0|%A|%B|%C|%D|%E|%F|127\.0).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(globals|encode|localhost|loopback).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(request|select|insert|union|declare).* [NC]
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in_.*$
RewriteRule ^(.*)$ - [F,L]
</IfModule>
当用户试图在一些论坛页面上使用搜索表单时,它会导致403个错误。这是搜索的一个示例:

<div class="search-box">
<form method="post" id="forum-search" action="./search.php?fid[]=5">
<fieldset>
<input class="inputbox search tiny" type="text" name="keywords" id="search_keywords" size="20" value="Search this forum…" onclick="if (this.value == 'Search this forum…') this.value = '';" onblur="if (this.value == '') this.value = 'Search this forum…';" />
<input class="button2" type="submit" value="Search" />
<input type="hidden" value="5" name="fid[]" />
</fieldset>
</form>
</div>
被禁止回来。当我取出.htaccess的那一部分时,它工作得很好。我了解.htaccess的基本知识,但不明白为什么该代码会导致HTML/PHP的该部分出现403错误


如果您有任何想法,我们将不胜感激……谢谢……

这将导致403,因为您在htaccess中返回403,您的重写规则中的F标志将如下所示


你这么做可能是有原因的。第一条规则通过HEAD、TRACE、DELETE和TRACK方法阻止请求。第二条规则使用一组可能的查询字符串和*来阻止请求,如果您缺少cookie中的wordpress\u logged\u*。因此,如果您没有一个名为wordpress\u登录的cookie,那么您将得到一个403。

非常感谢您的解释。我从另一个网站上得到了这段代码,目的是使wordpress更加坚固。我想问题是,因为我已经将我的phpbb论坛包装在wordpress中,论坛用户肯定不会登录wordpress,因此正如你所说的——获得403。也许这太危险了,不能使用,因为它破坏了我的phpbb搜索功能。不过我还是想用它,如果有办法让它在phpbb上玩得更好。@CC如果你的phpbb论坛位于一个目录中,你可以使用RewriteCond%{REQUEST_URI}之类的方法排除该目录^/论坛否则,您需要找到特定于论坛的内容,您可以将其排除在外。谢谢我可以试一下。很抱歉,关于重写规则,我听起来很傻但是如果我的phpbb论坛安装在这里:/pubic_html/forums,那么我猜。/forums-我应该在哪里以及如何编写重写条件,以将整个规则排除在我的/forums目录之外?