子域的PHP重定向问题 [英] PHP Redirect problem with subdomain

查看:34
本文介绍了子域的PHP重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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.

我遇到的问题是,如果引用看起来像 http://subdomain.domain.com/test.php?id=13,则重定向最终会转到 <代码>http://subdomain.domain.com/.domain.com/test.php?id=13.注意 url 中额外的 .domain.com/.

The problem I'm running in to is that if the referer looks like http://subdomain.domain.com/test.php?id=13, the redirect ends up going to http://subdomain.domain.com/.domain.com/test.php?id=13. Notice the additional .domain.com/ 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: http://subdomain.domain.com/test2.php");

test.php contains only header("Location: http://subdomain.domain.com/test2.php");

curl --head --referer 'http://subdomain.domain.com/' 'http://subdomain.domain.com/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.com/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重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆