ugly but efficient php programming

We have a site. The DirectoryIndex (index.php) redirects the user to the starting page based on the browser language or language cookie.

header("Location: ".$base . $lang."/concept.php");

The SEO problem is that google does not like these redirects. But we have a pretty complex structure there, and changing the way files are included/required means changing everything. And since we will completely replace the entire site in aprox. 4 month time…. we were looking for a “simple solution”.

And, tadaaa – that’s our solution. And it works:

echo file_get_contents($base . $lang."/concept.php");

Further reading: PHP: file_get_contents – Manual

However, this shouldn’t be considered the way to go, unless you really have a good reason to. So do NOT consider it a best practice

Leave a Reply

Your email address will not be published. Required fields are marked *