简体   繁体   中英

Htaccess rewrite with question mark

I have this type of link :

http://www.domain.it/index.php?module=Test&func=Prova

I would that when i add /en before /index.php

rewrite with

http://www.domain.it/index.php?module=Test&func=Prova&lang=en

I tried several methods but always rewrite index.php&lang=en The problem seems to be ?

RewriteRule ^(en)/(.*)$ $2&lang=$1 [L,QSA]

but nothing to do.

You can try adding those lines to your .htaccess file:

RewriteEngine On
RewriteRule ^([a-z]{2})/(.*)$ $2?%{QUERY_STRING}&lang=$1 [L]

This will save the language in $1 and the origin in $2 so it can be used from other pages, besides index.php and with other languages besides en .

Also, to test those things, you can use sites like this one.

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