LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   using header('location:... (https://www.linuxquestions.org/questions/programming-9/using-header-location-661015/)

syok 08-06-2008 07:54 PM

using header('location:...
 
hello there,
i'm not sure what is wrong.Just a simple application using header

<?php
header('location: http://192.168.80.5/info.php');
?>

save as justinfo.php

when i type 192.168.80.5/justinfo.php from 192.168.80.10 browser will direct me to 192.168.80.5. ok fine. Confirm this with access_log in 192.168.80.5 showed incoming request from 192.168.80.10

but execution in cron job or run as batch does not take place.
example:
/usr/bin/php5 -q justinfo.php will not show any incoming request in access_log


i'm sending get variable to another server triggered by cron job and target server is on windows.
example

<?php
...get record from db
header('location: http://anotherserver/fromme.aspx?var1=$var&var2=$var2');
?>

how to do that?

AdaHacker 08-06-2008 10:56 PM

Quote:

Originally Posted by syok (Post 3239273)
/usr/bin/php5 -q justinfo.php will not show any incoming request in access_log

Well, of course it won't. You're directly executing it - it's not running through the web server. All that script does is print out an HTTP header which, if you just run it on the command line like that, is the equivalent of printing "Hello, world" and exiting.

If you want that script to redirect to another server, then you need to request it via HTTP. So instead of directly running it with the PHP CLI interpreter, run it via lynx or wget, e.g. wget http://192.168.80.5/justinfo.php.


All times are GMT -5. The time now is 03:22 PM.