Reputation: 127
Trying to setup a multi-language website but having trouble with rewriting URLs.
Current .htaccess gets rid of the need to specify the .php extension as below:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
So gettext already setup and got a few languages translated and the url to switch the language is as below:
mysite.com/news?locale=en_US
mysite.com/news?page=2&locale=zh_TW
mysite.com/press?page=3&locale=it_IT
However my ultimate goal is to use like this:
mysite.com/en/news <= translated => mysite.com/news?locale=en
mysite.com/zh_tw/news/2 <= translated => mysite.com/news?page=2&locale=zh_TW
mysite.com/it/press/3 <= translated => mysite.com/press?page=3&locale=it
Can anyone enlighten me to the right direction, thanks.
Upvotes: 0
Views: 1009
Reputation: 1284
RewriteRule ^([^/]+)/([^/]+)$ $2?locale=$1 [QSA,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+) $2?page=$3&locale=$1 [QSA,L]
Upvotes: 2