我们遇到了htaccess重定向问题,希望能够获得解决方案。我们需要重定向网址(主要在内部搜索返回后生成),类似于:
domain.com/pretty-much-any-char-1/.../pretty-much-any-char-N/?folder=fr
domain.com/pretty-much-any-char-1/.../pretty-much-any-char-N/?folder=es
domain.com/pretty-much-any-char-1/.../pretty-much-any-char-N/?folder=cn
domain.com/pretty-much-any-char-1/.../pretty-much-any-char-N/?folder=pt
domain.com/pretty-much-any-char-1/.../pretty-much-any-char-N/?folder=ja
到
domain.com/fr/pretty-much-any-char-1/.../pretty-much-any-char-N/
domain.com/es/pretty-much-any-char-1/.../pretty-much-any-char-N/
domain.com/cn/pretty-much-any-char-1/.../pretty-much-any-char-N/
domain.com/pt/pretty-much-any-char-1/.../pretty-much-any-char-N/
domain.com/ja/pretty-much-any-char-1/.../pretty-much-any-char-N/
值得注意的是,要告诉您我们在.htaccess中已经有以下规则:
RewriteRule ^(fr|es|cn|pt|ja)/(.*) $2?folder=$1 [L,QSA,NC]
谢谢你的时间!
答案 0 :(得分:0)
试试这个
RewriteCond %{QUERY_STRING} folder=(.*)$
RewriteRule ^domain.com(.*)$ domain.com/%1$1?
RewriteRule ^(fr|es|cn|pt|ja)/(.*) $2?folder=$1 [L,QSA,NC]
编辑:
RewriteRule ^(?:www\.)?domain.com(.*)$ www.domain.com/%1$1?
那个适用于“www.domain.com”和“domain.com”