Reputation: 79
In a website I found, they use friendly URLs like this:
Real URL:
example.com/index.php?mode=product
FRIENDLY URL
example.com/view/product.html
In the friendly URL, there is a feature to get a variable with $_GET function. So if the URL looks like this:
FRIENDLY URL 2
example.com/view/product.html?id=10&lang=en&cur=1
This is similar to the friendly URL but allows me to easily access variable parameters.
Can someone help me write an .htaccess rewrite rule like this?
Upvotes: 1
Views: 1576
Reputation: 12038
The [QSA] directive in mod_rewrite is your friend here. It will append all the other query string parameters onto the end of the rewritten url:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^view/(.*).html /index.php?mode=$1 [QSA]
That is untested, but just a quick answer that should get you going.
Upvotes: 1