New answer after added details from the OP.
English users should be redirected, but Swedish user should stay on this site, so we'll rewrite the code like this (I added comments with // Reeno
):
<?php
include ('administration/fonts.php');
$lc = ""; // Initialize the language code variable
// Check to see that the global language server variable isset()
// If it is set, we cut the first two characters from that string
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
// Reeno: I added strtolower() if some browser sends upper case letters
$lc = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
}
// Now we simply evaluate that variable to detect specific languages
// Reeno: Redirect all non-Swedish users to the English page (they can have "en", but also "dk", "de", "fr"...
if($lc != "sv"){
header("location: http://www.domain.com/en.php");
exit();
}
// Reeno: Swedish users stay on this site
?>
HTML code...
Old answer
You check for $lc == "sv"
and $lc == "en"
but you forgot the third case: $lc
could be empty!
Rewrite the if at the end like this, so everybody with a non Swedish browser will get to en.php
:
if($lc == "sv"){
header("location: index.php");
exit();
}
else {
header("location: en.php");
exit();
}
?>
btw header("location: ...");
requires an absolute URI like header("location:http://www.domain.com/en.php");
(some clients also accept relative URIs)