【发布时间】:2021-06-08 18:09:54
【问题描述】:
我的 .htaccess 中有一个有效的 mod_rewrite cond/rule 可以完美地停止 HTTP OPTIONS 请求。
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^OPTIONS
RewriteRule .* - [F]
我也有 Apache 配置(用于腰带和大括号):
<Location />
<LimitExcept GET POST>
order deny,allow
deny from all
</LimitExcept>
</Location>
正如这里的最佳答案所建议的那样:Disable OPTIONS HTTP on Apache Server
然而,WordPress 将以下内容添加到同一个 .htaccess 文件中:
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>
# END WordPress
这样做会杀死我的 HTTP OPTIONS 杀手,这可以在对此请求的响应中看到:
> curl -i -X OPTIONS https://www.MYWEBSITE.co.uk/
HTTP/1.1 302 Found
Server: Apache
X-Redirect-By: WordPress
....
我尝试将这两个 mod_rewrite 规则组合成多种组合。我要么得到 500,要么 WordPress 网站运行良好并且 OPTIONS 请求得到尊重。
如何让 WordPress 网站正常工作,同时对 HTTP OPTIONS 请求发出拒绝响应?
【问题讨论】:
标签: wordpress mod-rewrite