also handle index.php URLs and better language detection