location header not working properly

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
kenknight
-


Joined: 10 May 2007
Posts: 8

PostPosted: Thu Oct 18, 2007 5:25 am    Post subject: location header not working properly Reply with quote

Hi all,

We're seeing a problem on a temporary server that we have setup using Abyss.

If we make a call to;

prospect.ammre_1205.propertyboss.net

it uses a location header statement to redirect to

http://prospect.ammre_1205.propertyboss.net/PropertyWebHQ/prospect/SearchHomesSelect.php?customer=ammre_1205&type=searchhomes

however, it is not passing the info passed the .net statement


IIS operates fine with this. Any suggestions on where to look?

THanks,
Ken
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Oct 22, 2007 4:55 pm    Post subject: Re: location header not working properly Reply with quote

kenknight,

Is the redirection generated by a script? If so, what is its source code? Otherwise, can you tell us what is causing that redirection?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
mario50
-


Joined: 26 Oct 2007
Posts: 9

PostPosted: Fri Oct 26, 2007 9:01 pm    Post subject: Re: location header not working properly Reply with quote

aprelium wrote:
kenknight,

Is the redirection generated by a script? If so, what is its source code? Otherwise, can you tell us what is causing that redirection?


Hi, I have the same problem here.

I use php code like this to redirect:

header("Location: /somewhere.php");

The php script works fine, redirected without a problem. However, the address bar of the browser did not update properly. And the location info read by JS script will remain the same as it was before the redirection.

Any clue?

Thanks!
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Tue Nov 13, 2007 3:10 pm    Post subject: Re: location header not working properly Reply with quote

mario50,

Are you using a frame? What is the browser you're testing with?

Check you access.log file to know if the browser is requesting the redirected page.

If not, this means that the server did an internal redirection (which is unlikely, but we'll ask our developers about that behavior).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
mario50
-


Joined: 26 Oct 2007
Posts: 9

PostPosted: Tue Nov 13, 2007 8:04 pm    Post subject: Re: location header not working properly Reply with quote

aprelium wrote:
mario50,

Are you using a frame? What is the browser you're testing with?

Check you access.log file to know if the browser is requesting the redirected page.

If not, this means that the server did an internal redirection (which is unlikely, but we'll ask our developers about that behavior).


Thanks for asking!

I'm not using a frame (that would be a super low-level mistake), the browser if Safari.

The test case would be:
/index.php:
<?php header("Location: /second.php"); ?>

and by visiting http://127.0.0.1/, the browser successfully displays the content of second.php, but the location bar stays still.

The $_SERVER["REQUEST_URI"] will display the old location as well. So AJAX apps may break. But I've found out that there is a $_SERVER["ORIG_REQUEST_URI"] that has the new location. So this is a work-around for ajax apps.

So I guess this is kind of a "feature" but definitely not a good one.

:-)
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Nov 14, 2007 2:24 pm    Post subject: Re: location header not working properly Reply with quote

mario50,

It's internal redirection in action. That's not a bad feature since it saves your system a whole response-request. The downside is that it behaves as you described.

To force a classical redirection, add the following header() statement before sending Location:

Code:
header("Status: 301");


This will force an external redirection and a behavior like the one you've been expecting.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
hbr
-


Joined: 24 Nov 2006
Posts: 1

PostPosted: Wed Jan 09, 2008 8:56 am    Post subject: Reply with quote

hi,

I also had some problems with php redirections.

Every header ("Location: URL") did not work, if a form's action IS A.PHP where I do a header("Location B.PHP"), the script stops at A.PHP and shows A.PHP in the address bar.

The problem persisted even after reinstalling XP Pro SP2 and Abyss 2.5/php5.2/Mysql5 .

I solved it by using 127.0.1.1 instead of localhost, it worked for few redirections and after that the problem appeared again :s
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Jan 09, 2008 9:38 pm    Post subject: Reply with quote

hbr,

Please contact our technical support about that issue.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Vahn
-


Joined: 10 Aug 2005
Posts: 51
Location: At my computer

PostPosted: Mon Jan 28, 2008 1:08 am    Post subject: Reply with quote

you should also note that if you have something like this:

Code:

<Html>
   <Head>
      <?php
         header("Location: Redirectto.php");
      ?>
and so on...


it should cause problems

something like:

Code:

<?php
   echo 'Yay i win!';
   header("Location: Redirectto.php");
?>


-should- also cause problems..

there shouldn't be any output before the header line, you can have code, but no output....

now i tried to do some " lets mess it up on purpose " but it worked anyways >.> idk if thats good or bad, mind if we can see some of the a.php ( from the beginning up to the header line should be good. )

-Vahn
_________________
A ship in the harbor is safe, But thats not what Ships were Built for. ~ John Shedd
Success Comes before Work only in the Dictionary ~ Harvey Mackay
Back to top View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group