开发者

Need to redirect Apache for just certain HTTP methods

开发者 https://www.devze.com 2023-03-02 04:11 出处:网络
Is there a way to do a redirect conditionally on the HTTP request method/verb? I want to redirect all PROPFIND requests to the document root, so that:

Is there a way to do a redirect conditionally on the HTTP request method/verb? I want to redirect all PROPFIND requests to the document root, so that:

PROPFIND / HTTP/1.1

is redirected to /MyApp/carddav/, but

GET / HTTP/1.1

is ha开发者_开发知识库ndled normally. The reason I need to do this is because the CardDAV implementation in OS X Address Book always expects to be able to contact the CardDAV server at /, and I'm running it at /MyApp/carddav/ with Tomcat.

Ideally, this could be done with an .htaccess file that a user could simply drop into their web server document root, rather than modifying the httpd.conf file, but I could live with either approach.


I figured it out. I added this to the end of my httpd.conf file:

RewriteEngine on
RewriteCond  %{REQUEST_METHOD}  ^PROPFIND$
RewriteRule  ^/$                 /MyApp/carddav/  [R,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消