views:

11

answers:

1

My sites are in 4 languages and they are accessed with the following pattern:

http://example/index.php?lang=en
http://example/index.php?lang=es
http://example/index.php?lang=zh-tw
http://example/index.php?lang=zh-cn

I'm using the following mod_rewrite rule in my .htaccess file:

RewriteEngine on
RewriteRule ^([a-z]{2}(-[A-Z]{2})?)/(.*) $3?lang=$1 [L,QSA]

So typing http://example/en/index.php and http://example/es/index.php efectively redirects me to http://example/index.php?lang=en and http://example/index.php?lang=es respectively. But that doesn't work with http://example/index.php?lang=zh-tw and http://example/index.php?lang=zh-cn

It just says: The requested document was not found on this server.

It is something to do with the hyphen (zh-tw and zh-cn)?

How can I fix this problem?

+2  A: 

Replace [A-Z] with [a-z].

Maerlyn
@Maerlyn Yes thanks I just figured out that! So can I just delete the [a-z] at the front?
janoChen
@janoChen No, keep it, it is still neccesary, that catches the part before the hyphen.
Maerlyn