我正在使用 PHP 将页面重定向回上一页,内容如下:
I'm using PHP to redirect a page back to the previous page with the following:
header("Location: {$_SERVER['HTTP_REFERER']}");这组页面仅供内部用户使用,因此我并不十分担心引用者并不总是可用的事实.
This set of pages will only be used by internal users, so I'm not terribly concerned about the fact that the referer will not always be available.
我遇到的问题是,如果引用看起来像 subdomain.domain/test.php?id=13,则重定向最终会转到 subdomain.domain/.domain/test.php?id=13.注意 url 中额外的 .domain/.
The problem I'm running in to is that if the referer looks like subdomain.domain/test.php?id=13, the redirect ends up going to subdomain.domain/.domain/test.php?id=13. Notice the additional .domain/ in the url.
我已经通过对值进行硬编码进行了测试,它也会导致问题.phpMyAdmin 似乎遇到了同样的问题,但仅限于这个特定的服务器.
I've tested by hardcoding the value, and it causes the problem as well. phpMyAdmin seems to suffer the same issue, but only on this particular server.
如果这不是一个 SO 问题,请相应地移动.
If this is not an SO question, please move accordingly.
编辑:根据@yaggo
test.php 只包含 header("Location: subdomain.domain/test2.php");
test.php contains only header("Location: subdomain.domain/test2.php");
curl --head --referer 'subdomain.domain/' 'subdomain.domain/test.php' HTTP/1.1 302 Found Server: nginx/0.7.64 Date: Fri, 02 Apr 2010 17:21:45 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive X-Powered-By: PHP/5.2.12-pl0-gentoo Location: .domain/test2.php 推荐答案看来是你的 nginx 配置导致了问题.
It seems that your nginx configuration is causing the problems.
nginx 完全有可能修改响应头.这不是默认设置 - 您可以有一个旨在使其充当反向代理等的配置.
Its totally possible that nginx is modifying the response headers. This is not by default - you could have a configuration that is aimed for it to behave as a reverse proxy etc.
您是否尝试过使用默认配置在 nginx 上测试重定向?
Have you tried testing the redirect on a nginx with its default configuration?
更多推荐
子域的PHP重定向问题
发布评论