I dont know why this is not working in this htaccess rule:
I want that friendly url can get 2 querystring params and it works fine, but the problem is the position that each param has in querystring.
I cant know the exact position of $2 and $3.
This is the url to try…
http://myweb.com/ferrari-testarossa-car-id460?aa=red&bb=coupe
And this is my rule…
RewriteRule ^[A-Za-z0-9-+.]+-id([0-9]{1,5})[?]?([a-z0-9-_]*[=]?[a-z0-9]*[.]?[a-z0-9]*)&([a-z0-9-_]*[=]?[a-z0-9]*[.]?[a-z0-9]*)$ car-profile.php?idModel=$1&$2&$3 [QSA,L]
I would need to pass key and value (both together) like this "aa=red" y "bb=coupe" to destination url as $2 and $3
How can i do this?
1000 thanks
2
Answers
finally.....I got it!
This is the correct regular expression:
When we put the flag "[QSA]", entire querystring will be passed concatenated to $ 1 parameter, so, into your php page, you can get each value within typical $GET["param"]
Example: for this input url:
this will be got as output url:
It was easier than i thought.
Thnaks a lot for everyone
With your shown samples, could you please try following.
Please make sure to clear your browser cache before testing your URLs.