大网数据广告活动
网站运营与故障问答

Apache HTTP server and redirect-carefully

· 52CE 我爱测

I checked a server's configuration file and saw ' redirect-carefully ' setting. Checking the docs: redirect-carefully This forces the server to be more careful when sending a redirect to the client. This is typically used when a …

问题原文

原帖链接 · Tero Lahtinen · CC BY-SA 3.0

I checked a server's configuration file and saw 'redirect-carefully' setting.

Checking the docs:

redirect-carefully

This forces the server to be more careful when sending a redirect to the client. This is typically used when a client has a known problem handling redirects. This was originally implemented as a result of a problem with Microsoft's WebFolders software which has a problem handling redirects on directory resources via DAV methods.

https://httpd.apache.org/docs/2.4/env.html

This does not say much on how exactly the server behaves differently when redirect-carefully is set.

What exactly does it mean to "be more careful when sending a redirect"?

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

... a problem handling redirects on directory resources via DAV methods.

This would seem to be the key point here. Normally, mod_dir (with the help of the DirectorySlash directive - which is On by default), will append a trailing slash on all slashless directory requests with a 301 redirect. ie. example.com/subdir gets 301 redirected to example.com/subdir/. This would seem to be regardless of what method is used in the request: GET, POST, including the WebDAV methods COPY, LOCL, MKCOL, etc.

Setting the redirect-carefully environment variable would seem to prevent this redirect from occurring on these WebDAV methods, which can otherwise cause problems. Or more specifically, the redirect only occurs on GET requests. (Note that this excludes POST requests - but POST data is lost during a 301 redirect anyway, and besides, you probably shouldn't be sending POST requests to a "directory" anyway.)

This is the only resource I found that backs this up:

Setting the environment variable "redirect-carefully" fixes some issues with various Web Folder applications that do not handle Redirect requests correctly. Normally mod_dir would respond to all requests for the URL http://servername/dav with a redirect request to http://servername/dav/. With "redirect-carefully" set this will now only happen for GET requests.

Source:
http://www.deltadevelopment.de/users/christoph/webdav/

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。