Reputation: 427
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.
Upvotes: 2
Views: 44
Reputation: 2195
Try the following:
RewriteRule ^/(cz|en)/(.*)$ $2.php?lang=$1 [L]
RewriteRule ^/(cz|en)/([^/]+)/(.*)$ $2.php?lang=$1&string=$3 [L]
Upvotes: 0
Reputation: 41229
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.
Upvotes: 0