需要为某些 HTTP 方法重定向 Apache
有没有办法对 HTTP 请求方法/动词进行有条件的重定向?我想将所有PROPFIND请求重定向到文档根目录,这样:
PROPFIND / HTTP/1.1
被重定向到/MyApp/carddav/,但
GET / HTTP/1.1
正常处理。我需要这样做的原因是因为 OS X 地址簿中的 CardDAV 实现始终期望能够联系位于 / 的 CardDAV 服务器,并且我使用 Tomcat 在 /MyApp/carddav/ 上运行它。
理想情况下,这可以通过 .htaccess 文件来完成,用户可以简单地将其放入其 Web 服务器文档根目录中,而不是修改 httpd.conf 文件,但我可以接受这两种方法。
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 handled 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了。我将其添加到 httpd.conf 文件的末尾:
I figured it out. I added this to the end of my httpd.conf file: