如何将/?lang = en重定向到/en? [英] How can i redirect /?lang=en to /en?
本文介绍了如何将/?lang = en重定向到/en?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法将多语言网站重定向到一页.我对htaccess的重定向无法正常运行.我需要有关如何完成此操作的帮助.在我的htaccess中,当我添加这两行时
I'm having trouble redirecting a multilingual website one page. My redirection to htaccess doesn't operate properly. I need assistance with how this can be done. In my htaccess, when I add these two lines
RewriteCond %{QUERY_STRING} ^lang=en$
RewriteRule ^ /en? [R=301,L]
重定向工作,但未找到mysite.com/en显示404.有人帮我吗?
redirect working, but mysite.com/en show 404 not found. Someone help me with this?
推荐答案
您所显示的重定向规则运行正常.您还需要一个重写规则来处理/en
:
Your redirect rule as shown in question is working fine. Bot you also need a rewrite rule to handle /en
:
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$
RewriteRule ^ /%1? [R=301,L]
RewriteRule ^([a-z]{2})/?$ ?lang=$1 [QSA,L]
这篇关于如何将/?lang = en重定向到/en?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文