IIS7上的PHP - 接收"Object Moved"html页面而不是实际重定向

Nat*_*ley 6 php iis iis-7.5

我正在使用IIS7.5作为Web服务器在我的计算机上学习PHP,并且在正确完成301重定向时遇到问题.

教程和论坛都说要使用以下内容:

Header('Location: ' . $url, true, 301);
Run Code Online (Sandbox Code Playgroud)

要么

Header('Location: ' . $url);
Run Code Online (Sandbox Code Playgroud)

在这两种情况下,浏览器(Chrome和Firefox)都显示以下内容,而不是实际重定向:

Object Moved

This document may be found here
Run Code Online (Sandbox Code Playgroud)

使用FireFox Web开发人员工具栏,我检索了页眉,其中包括:

Content-Type: text/html; charset=UTF-8
Server: Microsoft-IIS/7.5
X-Powered-By: PHP/5.3.5, ASP.NET
Date: Mon, 21 Mar 2011 18:47:35 GMT
Content-Length: 123

301 Moved Permanently
Run Code Online (Sandbox Code Playgroud)

为什么页面不重定向?显示该页面对于用户来说是多余的并且令人讨厌.

Nat*_*ley 3

我想到了。Location 标头必须是自动重定向的绝对路径。如果它是相对路径,则不会重定向。