在网站根目录目录下创建.htaccess文件,内容如下,如果您已有其他规则,请添加到第一条规则
```
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(OPTIONS)
RewriteRule .* - [F]
```
**使用Apache的重写规则来禁用Options方法和Trace方法**
在Apache配置文件httpd-conf中【vhosts-conf】添加以下代码:
- 单独禁用Trace方法:
```
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
```
- 单独禁用Options方法:
~~~
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(OPTIONS)
RewriteRule .* - [F]
~~~
- 同时禁用Trace方法和Options方法
~~~
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS)
RewriteRule .* - [F]
<VirtualHost *:80>
DocumentRoot "D:\wwwroot"
ServerName www.abc.com
ServerAlias abc.com
<Directory "D:\wwwroot">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS)
RewriteRule .* - [F]
</Directory>
</VirtualHost>
~~~