开发者

help with URL rewrite for a multilanguage site with .htaccess (Apache)

开发者 https://www.devze.com 2023-01-06 10:45 出处:网络
I have a multilanguage site and I\'m trying to rewrite the URL\'s with a fake directory something like this:

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&am开发者_运维知识库p;cat=$2&lang=$3 [NL,QSA]

This resolves as a 404 error.

Any help will be apreciate.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号