简体   繁体   中英

htaccess redirect add querystring


I'm triying to redirect 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:

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 ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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