PDA

View Full Version : different header behaviors?


mothra
01-31-2004, 08:38 PM
On my development box (Apache/1.3.27 PHP/4.2.3) I have my root and sub directories set up the same as my hosts server does. I keep all of my php scripts in one directory and my content pages under the root and/or sub-directories under the root. When I call Header from a script it does not work on my hosts server, but it does work on my box. Here is an example:


This one works on my box, but not on hosts server

<?php
header("Location: /test.php");
?>


This is my fix, but why should I have to do this??

<?php
header("Location: HTTP://" . $_SERVER['HTTP_HOST'] . "/test.php");
?>


So what gives? Is it an issue with my host maybe? I don't know if it is related or not, but echoing $_SERVER[DOCUMENT_ROOT] does not return anything from the host either.

Spookster
01-31-2004, 08:49 PM
Are you on a shared hosting plan with your webhost? Is your development machine running MS Windows? Is your host running Linux?

mothra
01-31-2004, 08:50 PM
On a related note, can I dynamically check what the current protocol is and then send my header to correspond? Basically, if I'm redirecting from a document that is currently using HTTPS I want to make sure I send the HTTPS header not HTTP.

Thanks again.

mothra
01-31-2004, 08:54 PM
Yes it is shared hosting. Both my machine and the host are running MS.

Spookster
01-31-2004, 09:12 PM
Since you are using site-root relative paths the location of the site root on the host is likely to be different than the site root you have at home.

Also since you said your webhost is running MS Windows I would have to assume they are running IIS and not Apache since Apache is not really designed for heavy use on Windows.

mothra
01-31-2004, 11:52 PM
That tends to make sense. Thanks Spookster.