Saturday, April 20, 2019

PHP Header redirect not working

1) There should be NO output (i.e. echo... or HTML parts) before the header(...); command.


2) After header(...); you must use exit();


3) Remove any white-space(or newline) before and after ?> tags.


4) Check that php file (and also other .php files, that are included) -
they should have UTF8 without BOM encoding (and not just UTF-8). Because default UTF8 adds invisible character in the start of file (called "BOM"), so you should avoid that !!!!!!!!!!!


5) Use 301 or 302 reference:


header("location: http://example.com",  true,  301 );  exit;

6) Turn on error reporting. And tell the error.


7) If none of above helps, use JAVASCRIPT redirection (however, discouraged method), may be the last chance in custom cases...:


echo ""; exit;

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...