Possible Duplicate:
Headers already sent by PHP
My website's main URL redirects any visitors to the local sub-pages, and I use freegeoip.net to achieve this, along with PHP:
<!DOCTYPE html>
<html>
<head>
<title>MLP Today</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="google-site-verification" content="*snip*" />
<?php
$csv = str_getcsv(file_get_contents('http://freegeoip.net/csv/'));
$geoloc = strtolower($csv[1]);
if ($geoloc == 'hu' ||
$geoloc == 'ro'){
header("Location: hu/");
}
else if($geoloc == 'nl' ||
$geoloc == 'be' ||
$geoloc == 'de' ||
$geoloc == 'sr' ||
$geoloc == 'au'){
header("Location: de/");
}
else {
header("Location: en/");
}
?>
<link rel="icon" type="image/png" href="img/favicon/favicon.png">
</head>
<body>
</body>
</html>
However, when loading the site from my local Apache Server, I get an error, saying:
Warning: Cannot modify header information - headers already sent by (output started at D:\DJDavid\Dokumentumok\Dropbox\Web\Today\index.php:7) in D:\DJDavid\Dokumentumok\Dropbox\Web\Today\index.php on line 13
Line 13 is: header("Location: hu/");
I read some answers before, but all of them was referring to live websites, not Apache Web-Servers. Some said I have to remove everything before & after the PHP code, but that did not help. Also, I'm not outputting or returning anything, as you can see, while that was the second most common cause of this problem. The third suggested was, to use ob_start()
, but that was no help either.
The thing is, it works perfectly on the web host, but not when I'm using localhost
(the local server) to preview changes before going live.
I'm guessing I have to change something in httpd.conf
but I don't know what.