25 September 2011

header ('Location: http://www.domain.com/blablabla.php') does not work


One minor problem when creating a website using php, this trivial problem sometimes hinder the work / logic that is more important.

One issue that is trivial: Header ("Location:");

As we all know that the tag header ("Location:"); in php function to send a redirect header or page to another.

At the time of failure, the classic problems that occur are:


1. There are output from the php header tags before

example:
echo "Sorry, you do not have access";
header ('Location: http://domain.web.id/blablabla.php');

The above example will thwart the command header, because there is prior output.

2. Php configuration problem

Check whether the buffer php php.info you active? (output_buffering = 1) if yes, then delete the numbers (1) and allow the setting to none

No comments:

Post a Comment