简体   繁体   English

htaccess重定向添加查询字符串

[英]htaccess redirect add querystring


I'm triying to redirect www.myweb.com to www.myweb.com/?lang=en 我正在尝试将www.myweb.com to www.myweb.com/?lang=en重定向www.myweb.com to www.myweb.com/?lang=en
Any try i made redirect all the traffic in the website or creates a loop. 我所做的任何尝试都会重定向网站中的所有流量,或创建一个循环。
Any help? 有什么帮助吗?

I thinkg it should be easier for you to set the GET variable lang to 'en' in php, rather than redirecting... In your code, before handling the lang variable, try: 我认为,在php中将GET变量lang设置为“ en”,而不是进行重定向应该更容易...在您的代码中,在处理lang变量之前,请尝试:

if (!isset($_GET['lang'])) {
    $_GET['lang'] = 'en;
}

If you need to do it via a rewrite rule for whatever reason, this worked for the simple example I tried: 如果出于某种原因需要通过重写规则来执行此操作,则可以使用我尝试过的简单示例:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ $1?lang=en [QSA]

Though there are similar questions on stack overflow you should check out: ModRewite and general searching ;) 尽管在堆栈溢出上也有类似的问题,但您应该检查一下: ModRewite和常规搜索;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM