I’ve been trying to get a redirect script to work but as I know nothing about php I am at a loss. I get a Warning:
[21-Apr-2015 13:08:52 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/pintotou/public_html/Links/links.php:7) in /home/pintotou/public_html/Links/links.php on line 9
The script is this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noarchive, noindex, nofollow, noodp, noydir" />
</head>
<?php
/* Redirect browser */
header("Location: http://www.dpbolvw.net/click-7089264-10925976-1428564451000?url=http%3A%2F%2Fwww.accorhotels.com%2Flien_externe.svlt%3Fgoto%3Drech_geo_nobar%26nom_ville%3Ddelhi");
/* Make sure that code below does not get executed when we redirect. */
die();
?>
<body>
</body>
</html>
PHP headers will only work as long as no content as been given to the browser to output. That example will only work if you do the following.
<?php
/* Redirect browser */
header("Location: THE ADDRESS TO BE LINKED TO");
/* Make sure that code below does not get executed when we redirect. */
die();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noarchive, noindex, nofollow, noodp, noydir" />
</head>
<body>
</body>
</html>
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
Sorry, maybe that’s rude, but I’ve seen this question five times last week.
Unintentional:
Whitespace before <?php or after ?>
And I’m not trying to offense you, sorry.
I’m just want to say there is 98% chance someone has already encountered any problem you get.
Just google it.