PHP on IIS7 - Receive & ldquo; Object Moved & rdquo; page html instead o...
source link: https://www.codesd.com/item/php-on-iis7-receive-object-moved-page-html-instead-of-actually-redirecting.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
PHP on IIS7 - Receive & ldquo; Object Moved & rdquo; page html instead of actually redirecting
I'm learning PHP on my computer with IIS7.5 as the web server and am having a problem completing a 301 redirect correctly.
The tutorials and forums all say to use the following:
Header('Location: ' . $url, true, 301);
Header('Location: ' . $url);
In both cases, instead of actually redirecting, the browser (Chrome and Firefox) display this:
Object Moved
This document may be found here
Using the FireFox web developer toolbar, I retrieved the page headers, which were:
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
Why is the page not redirecting? Displaying that page is kind of redundant and annoying for users.
I figured it out. The Location header must be an absolute path to auto-redirect. If it's a relative path it doesn't redirect.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK