子域的PHP重定向问题

编程入门 行业动态 更新时间:2024-10-26 02:25:47
本文介绍了子域的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.

我遇到的问题是,如果引用看起来像 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重定向问题

本文发布于:2023-11-01 11:27:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549216.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!