hello I get crazy through a header-function that does not work.
the idea is that when a user is calling the page foo.php he will be headered. therfor I included a script from script.php
the script reads out the information about the accepted languages from
$_SERVER[“HTTP_ACCEPT_LANGUAGE”])
okay, from that I have the preferred language and a country code that I need to header foo.php into the right language direction. the code from script.php is like:
if ($pref_language == 'af'){
header('Location:en'.$_SERVER['SCRIPT_NAME']);
exit;
}
if ($pref_language == 'sq'){
header('Location:en'.$_SERVER['SCRIPT_NAME']);
exit;
}
so these examples will header foo.php to directory of
root/en/foo.php
now when calling just script.php that is located in root/scripts/script.php I will headered root/en/scripts/script.php. thats why I would like to add the if-condition that
all if-statements with header(); only take place for files outside of root/scripts/.
so I added:
$filename = $_SERVER['SCRIPT_NAME'];
$path = $_SERVER['HTTP_HOST']."/scripts".$_SERVER['SCRIPT_NAME'];
if (isset($path == false)){
if ($pref_language == 'af'){
header('Location:en'.$_SERVER['SCRIPT_NAME']);
exit;
}
if ($pref_language == 'sq'){
header('Location:en'.$_SERVER['SCRIPT_NAME']);
exit;
}
}
that does not work. so if someone could help me out I really would appreciate.
thanks alot.
This can be your solution, although it’s kind of silly in a way, but will do the job:
another way would be a regular expression, but this is simplier
I advise you to make it more dynamic on selecting the language. i.e: