Reputation: 7603
I believe what I'm trying to do is simple but I've been at it for hours and can't find the solution. Basically I have a site that has 2 languages: English and French.
I would like that if the url has no language, it redirects to a page, but if a language is specified in the url, redirect to that page.
For example
www.mysite.com -> goes to index.php?lg=en&page=$1
www.mysite.com/fr goes to index.php?lg=fr&page=$1
In my htaccess file I have this
RewriteEngine On
RewriteBase /
RewriteRule ^fr(.*)$ index.php?lg=fr&page=$1 [L,QSA]
RewriteRule ^(.*)$ index.php?lg=en&page=$1 [L,QSA]
This isn't working. Any help would be much appreciated!
Thanks
EDIT : The code I have supplied is kind of working... the only thing is that it doesn't load my CSS/JS anymore.. when I try to type the whole path of the CSS/JS file, it returns a page not found... I know the path is good because if I comment the first rewriteRule the files get loaded... I have no clue why this is happening.
Upvotes: 0
Views: 1639
Reputation: 9400
Is RewriteEngine
directive set to On
in your Apache configuration? If not, the first line in your .htaccess should turn it on explicitly(RewriteEngine On
should be the first line in the .htaccess).
Also you don't really need the second rewrite rule, do you? If no lg
parameter is supplied via GET
, you can default it to en in your index.php script.
Upvotes: 1