繁体   English   中英

Header 位置重定向不通过重写更改域

[英]Header location redirect not changing domain with rewrite

我们有一个页面需要重定向到另一个页面。 通常,这是一件相对简单的事情。 但是,我们重定向到的页面位于另一个域上。 这页纸:

www.oursite.com/our-page.php

需要重定向到http://www.example.com/another-page.php

通常这是 php 中的一个简单事件。

header("Location: http://www.example.com/another-page.php");
die();

正确的? 我已经做了几十万次了。 但在这种情况下,我们通过 IIS 重写规则到达 our-page.php。 现在,当你点击页面时,浏览器会跳转到

www.oursite.com/another-page.php

无论我将什么放入 header 位置,它都坚持www.oursite.com I know the header is definitely being set, it's not giving me any header not set warnings, and it is trying to go to another-page.com.

我不知道的位置 header 是否有一些跨域限制? 我一直无法在网上找到任何东西。 在任何其他情况下页面重定向都很好,只是不使用重写规则

IIS 规则是:

<rule name="test" enabled="true" stopProcessing="true">

  <match url="^test/(.*)$" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />

  <action type="Rewrite" url="https://{HTTP_HOST}/our-page.php/?path={R:1}}" />

</rule>

还有更多事情要做,但我已将代码剥离,只设置位置 header。

我期望发生的是我 go 到http://www.oursite.com/test/some-path 将其重写为http://www.oursite.com/our-page/?path=some-path ,进而获得 header 集,用户最终访问Z80791B3AE7002CB88C246876D9FA/Ather。页.php

实际发生的是用户最终到达http://www.oursite.com/another-page.php (然后再次撞到我们的 404 页面,因为它不存在)

经过几周的挠头和疯狂的谷歌搜索。 我最终得到了一个相当粗略的解决方案。

我将应用程序从 IIS 服务器移动到 Apache 服务器,并将规则转换为 .htaccess 等效项。 可能不是理想的解决方案,因为这可能不是每个人都可以使用的选项,但是在我这样做之后,我就没有更多问题了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM