Reputation: 13
I'm new to apache's mod_rewrite and i'm having a problem ...
If i use the url : mysite.com/nl/ or mysite.com/fr/ i'm getting redirected to the right page, when a user enters the url mysite.com i redirect my user to the nl language but the problem is in the adress bar the url stays mysite.com and i would like it to be mysite.com/nl
this is my htaccess file:
RewriteEngine on
DirectoryIndex index.php
RewriteBase /
# Rewrite voor taal en pagina
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ $1/$2 [R]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?tl=$1&pg=$2 [L]
#rewrite voor taal
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ $1 [R]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?tl=$1 [L]
my folder structure is:
[nl]
index.php
contact.php
[fr]
index.php
contact.php
index.php
the content of index.php (in the root directory):
<?
switch ($_REQUEST['tl'])
{
case 'nl':
switch ($_REQUEST['pg'])
{
case 'contact':
include_once("nl/contact.php");
break;
default:
include_once("nl/index.php");
break;
}
break;
case 'fr':
include_once("fr/index.php");
break;
default:
include_once("nl/index.php");
break;
}
?>
So when a users enters mysite.com it shows the index.php from the nl directory but the url in the browser address stays mysite.com but should be mysite.com/nl/
Since i have zero experience in this rewriting rules i've been stuck at it for hours ...
Thanks in advance,
Davidi
Upvotes: 1
Views: 140
Reputation: 1804
Instead of using include_once
try using header('Location: /nl/page.php')
or header('Location: /fr/page.php');
Upvotes: 1