.htaccess tutorial

htaccess Elite


multi language site with fake folders

Ask your mod_rewrite and Redirection questions here, and get answers!

multi language site with fake folders

New postby niVin » 14 Nov 2009 01:42

Hey members,

Im struggling for the last 2 days without any concrete results. I have setup a multi lingual website (dutch (default), english and german) with php. choosing a language is done by setting a $_GET var like ?lang=en.
But for pretty url's I decided to create 3 'fake' folders for the corresponding languages.

My website structure (htaccess in localhost/mywebsite/public):

localhost/mywebsite/public/index.php (and like index.php, also a few other pages like products.php etc.)

In the moment I can call the website by localhost/mywebsite/public/nl and with:
Code: Select all
RewriteBase /mywebsite/public
RewriteRule ^(nl|en|de|NL|EN|DE)/(.*) $2?lang=$1 [NC,L,QSA]
RewriteRule ^(nl|en|de|NL|EN|DE)$ http://localhost/mywebsite/public/$1/index.php [R=301,L]

It is rewrited to localhost/mywebsite/public/index.php?lang=nl

Ok this works. but now comes my headache. I want the public folder removed from the url + I need one language as default so I would like to call the website from:
localhost/mywebsite and then it needs to redirect directly to localhost/mywebsite/nl. I tried it with putting the htaccess in the webiste root ( localhost/mywebsite) but then the above RewriteRules dont work anymore..

any suggestions?
Thanks n advance
niVin
 
Posts: 1
Joined: 13 Nov 2009 23:37

Return to Redirect or Rewrite Questions