leesiulung Posted May 22, 2007 Share Posted May 22, 2007 I use the following code to redirect: <?php header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.mydomain.com/"); exit(); ?> However, when checking the headers sent, the text after the code 301 gets chopped off. I tried different codes too... Can anyone see anything wrong with this? I eventually solved it by using .htaccess file instead, but would like to get to the bottom of this. Link to comment https://forums.phpfreaks.com/topic/52516-header-does-not-seem-to-work-correctly-read-the-stickey/ Share on other sites More sharing options...
leesiulung Posted May 25, 2007 Author Share Posted May 25, 2007 Nobody has a suggestion? I just find it odd that I get the whole header, but parts of the header is missing. Does anyone ever check the headers to ensure it is doing the correct thing? Link to comment https://forums.phpfreaks.com/topic/52516-header-does-not-seem-to-work-correctly-read-the-stickey/#findComment-261840 Share on other sites More sharing options...
per1os Posted May 25, 2007 Share Posted May 25, 2007 Maybe try <?php header("HTTP/1.0 301 Moved Permanently"); header("Location: http://www.mydomain.com/"); exit(); ?> Other than that it seems like it should work to me. EDIT: Found this on www.php.net/header in the user comments: jherman at digitalgravy dot net 17-May-2006 05:16 PHP as CGI treats header differently. header("HTTP/1.0 404 Not Found"); returns "404 ok" When using PHP (3,4 and 5) as CGI to return a 404 you need to use: header("Status: 404 Not Found"); this returns "404 Not Found" See: http://bugs.php.net/bug.php?id=27345 Perhapd you have PHP installed as CGI? Link to comment https://forums.phpfreaks.com/topic/52516-header-does-not-seem-to-work-correctly-read-the-stickey/#findComment-261846 Share on other sites More sharing options...
leesiulung Posted May 26, 2007 Author Share Posted May 26, 2007 Yeah, it is installed as a CGI. However, in my case the header returned is: header("HTTP/1.0 301 Moved Permanently"); -> "HTTP/1.0 301" Incomplete header... Is that the same problem as the '404 ok' error header you suggested? Link to comment https://forums.phpfreaks.com/topic/52516-header-does-not-seem-to-work-correctly-read-the-stickey/#findComment-261938 Share on other sites More sharing options...
per1os Posted May 26, 2007 Share Posted May 26, 2007 Did you try using this: header("Status: 301 Moved Permanently"); OR header("HTTP/1.0 301 Moved Permanently\r\n"); // dunno if this is proper but \r\n usually ends the header line. Link to comment https://forums.phpfreaks.com/topic/52516-header-does-not-seem-to-work-correctly-read-the-stickey/#findComment-262077 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.