在 Apache 服务器上禁用 OPTIONS HTTP
Disable OPTIONS HTTP on Apache Server
Request:
OPTIONS / HTTP/1.1
Host: webcat.staci.com
Connection: Keep-alive
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.21
Accept: */*
Response:
HTTP/1.1 200 OK
Date: Thu, 01 Oct 2015 12:24:59 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Allow: GET,HEAD,POST,OPTIONS,TRACE
Vary: Accept-Encoding,User-Agent
Content-Length: 0
Keep-Alive: timeout=7, max=95
Connection: Keep-Alive
Content-Type: httpd/unix-directory
Set-Cookie: BIGipServerwebcat-ssl=192938503.47873.0000; path=/; httponly; secure
我想在我的 Apache 服务器上禁用 HTTP 选项,但我想保留 GET
、POST
并且我想 PING
我的服务器。
我该怎么做?
我的httpd.conf:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} !^ (GET,POST,HEAD)
RewriteRule .* – [R=405,L]
无法使用 RewriteCond 禁用 OPTIONS 方法。
您必须使用 LimitExcept 指令禁用。
下面是可以添加到 Apache 配置之外的片段:
<Location />
<LimitExcept GET POST>
order deny,allow
deny from all
</LimitExcept>
</Location>
请不要忘记重新启动网络服务器:)
如果您想将其应用于特定项目:
只需将这些行添加到 .htaccess
文件就可以了:
RewriteCond %{REQUEST_METHOD} ^(OPTIONS)
RewriteRule .* - [F]
要使其正常工作,请确保您已启用 mod_rewrite
并在这些行之前使用 RewriteEngine On
。
Request:
OPTIONS / HTTP/1.1
Host: webcat.staci.com
Connection: Keep-alive
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.21
Accept: */*
Response:
HTTP/1.1 200 OK
Date: Thu, 01 Oct 2015 12:24:59 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Allow: GET,HEAD,POST,OPTIONS,TRACE
Vary: Accept-Encoding,User-Agent
Content-Length: 0
Keep-Alive: timeout=7, max=95
Connection: Keep-Alive
Content-Type: httpd/unix-directory
Set-Cookie: BIGipServerwebcat-ssl=192938503.47873.0000; path=/; httponly; secure
我想在我的 Apache 服务器上禁用 HTTP 选项,但我想保留 GET
、POST
并且我想 PING
我的服务器。
我该怎么做?
我的httpd.conf:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} !^ (GET,POST,HEAD)
RewriteRule .* – [R=405,L]
无法使用 RewriteCond 禁用 OPTIONS 方法。 您必须使用 LimitExcept 指令禁用。
下面是可以添加到 Apache 配置之外的片段:
<Location />
<LimitExcept GET POST>
order deny,allow
deny from all
</LimitExcept>
</Location>
请不要忘记重新启动网络服务器:)
如果您想将其应用于特定项目:
只需将这些行添加到 .htaccess
文件就可以了:
RewriteCond %{REQUEST_METHOD} ^(OPTIONS)
RewriteRule .* - [F]
要使其正常工作,请确保您已启用 mod_rewrite
并在这些行之前使用 RewriteEngine On
。