views:

46

answers:

2

Hello, I have a multilanguage site and I'm trying to rewrite the URL's with a fake directory something like this:

http://localhost/theSite/page.php?id=param&cat=param?lang=en,fr,es to http://localhost/theSite/(en|fr|es)/page/param/param

.htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(fr|en|en)/(.*) $2.php?id=$1&cat=$2&lang=$3 [NL,QSA]

This resolves as a 404 error.

Any help will be apreciate.

+2  A: 

You're second capture will capture everything until the end of the URL. So it is possible you are doubling up on the extension or the wrong directory.

Although it shouldn't affect the redirect, you don't have a third capture, so where is $3?

Look at your headers and see where it is really redirecting to and comment back.

Jason McCreary
+3  A: 
RewriteRule ^(en|fr|es)/(.*?)/(.*?)/(.*) $2.php?id=$3&cat=$4&lang=$1 [NC,QSA]

I suppose you meant NC (no case), not NL. You referred to capture groups that didn't exist and repeated $2.

Artefacto
jartaud
No, you can do as in the rule in this answer, you just have to change the place of `(en|fr|es)`.
Artefacto
Thanks again, but it is possible to have a virtual folder for example (site/en/page) at the start, but when we click on a link (Español, Français) the folder change to es or fr??
jartaud