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]
精彩评论