Multi language website

New to mod_rewrite? This is a good place to start.

Multi language website

Postby dj_spykey » Sat Feb 06, 2010 12:41 am

Hellow so i got a multi language website, it will be english, italian and french, whats the easy way to do the url's like this:

-if the language is english or unset the urls will be / (BASE)
-if the language is set the urls will be /it/ OR /fr/

Example link:
mydomain.com/about-us.html
mydomain.com/it/about-us.html
mydomain.com/fr/about-us.html

I made this, but i dont really like how it works:
Code: Select all
RewriteEngine on

RewriteRule ^([A-Za-z0-9-]+)\.html$ page.php?name=$1
RewriteRule ^(it|fr)/([A-Za-z0-9-]+)\.html$ page.php?lang=$1&

RewriteRule ^projects/([A-Za-z0-9-]+)\.html$ projects.php?name=$1
RewriteRule ^(it|fr)/projects/([A-Za-z0-9-]+)\.html$ projects.php?lang=$1&page=$2

RewriteRule ^photos/([A-Za-z0-9-]+)-([0-9]+)\.html$ photos.php?name=$1&id=$2
RewriteRule ^(it|fr)/photos/([A-Za-z0-9-]+)-([0-9]+)\.html$ projects.php?lang=$1&page=$2&id=$3


Is there a better way, because i have like 50 more rewrite rules to do and i dont want to duplicate them all? I need to set the /en/ and the /it/ optional.
dj_spykey
 
Posts: 8
Joined: Mon Nov 03, 2008 11:39 pm

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 5 guests

cron