当HTTP方法是Apache .htaccess上的OPTIONS时,如何避免请求基本身份验证?

dse*_*ara 6 apache .htaccess http cross-domain preflight

我在包含Apache托管的API端点的站点中使用HTTP基本身份验证(用户名和密码),我在.htaccess上执行类似的操作:

AuthType Basic 
AuthName "Restricted Files"
# (Following line optional)
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require user rbowen
Run Code Online (Sandbox Code Playgroud)

由于我在另一个域上托管的页面中从浏览器端使用API​​(CORS部分已经解决),我需要允许某些请求未经身份验证.这些请求是请求哪个方法是"OPTIONS",(预检如下所述:http://www.w3.org/TR/cors/#resource-preflight-requests),请,我不需要任何关于ajax的信息或浏览器上的任何其他东西,我需要知道如何在apache上执行此操作

提前致谢

anu*_*ava 7

你可以mod_setenvif在这里使用.

SetEnvIfNoCase Request_Method OPTIONS allowed

AuthType Basic 
AuthName "Restricted Files"
# (Following line optional)
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require user rbowen
Order deny,allow
Deny from all
Allow from env=allowed
Satisfy any
Run Code Online (Sandbox Code Playgroud)