Hi all.
I want to have two languages on my website: english and german.
By doing this I am trying to pass two PHP variables between webpages: $page, and $lang.
I have been using this rewrite rule:
RewriteRule ^/(en|de)/([A-Za-z0-9]+)$ index.php?lang=$1&page=$2
but I cannot get it to work. A typical ‘a href’ link should then be something like “a href=”/en/news" or “a href=”…/en/news" in this case, right?
If I simply type in the variables in the URL like this:
?lang=de&page=news
it works fine and I can change the language to english by replacing “de” with “en” successfully and change the page variable easily.
However, I want a clean URL and would like to have:
instead where in this case “de” represents the ?lang value and “news” represents the ?page value.
If I put the .htaccess folder in the root folder, then I shouldn’t have to worry about subdirectories and the hierarchy of folders, correct?
PHP code:
<?php
if (!isset($_GET[‘page’])) {
$_GET[‘page’] = ‘home’;
}
$page = $_GET[‘page’];
?>
<?php
if (!isset($_GET[‘lang’])) {
$_GET[‘lang’] = ‘en’;
}
$lang = $_GET[‘lang’];
?>
My current folder directory is something like root->content->de->news.php
Sorry for the long post but I appreciate any help.