Pavel Straka
Pavel Straka

Reputation: 427

.htaccess mod_rewrite URL language

I would like to write a rule, that would redirect URL like this:

myweb.com/en/page

to

myweb.com/page.php?lang=en

This code:

RewriteRule ^/(cz|en)/(.*)$  $2?lang=$1 [L]

does not work (error 404). Thanks everyone.

Upvotes: 0

Views: 243

Answers (2)

Amit Verma
Amit Verma

Reputation: 41229

You dont need to match the leading slash in RewriteRule's pattern on htaccess context :

RewriteRule ^(cz|en)/(.*)$  $2?lang=$1 [L]

Upvotes: 0

Maths RkBala
Maths RkBala

Reputation: 2195

Try this following:

RewriteRule ^/(cz|en)/(.*)$  $2.php?lang=$1 [L]

Upvotes: 1

Related Questions