I would like to write a rule, that would redirect URL like this:
myweb.com/en/page
to
myweb.com/page.php?lang=en
And URL like this
myweb.com/en/page/SOME_TEXT(EVEN WITH SLASHES)
to
myweb.com/page.php?lang=en&string=SOME_TEXT
This code:
RewriteRule ^(cz|en)/(.*)$ $2?lang=$1 [QSA,L]
works for the language but not for the another text (SOME_TEXT).
What should I change? Thanks everyone.
Try the following:
RewriteRule ^/(cz|en)/(.*)$ $2.php?lang=$1 [L]
RewriteRule ^/(cz|en)/([^/]+)/(.*)$ $2.php?lang=$1&string=$3 [L]
You can use the following :
RewriteRule ^/?(cz|en)/([^/]+)/?(.*)$ $2.php?lang=$1&string=$3 [QSA,L]
?: is used to disable the capture group, so $1 now Contains the value of your second capture group.
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.