I have a url like:
shop/products.html?search_limiter=full&keyword1=apple
I want to rewrite this url to :
index.php?route=product/search&search=apple&description=true
using apache .htaccess
I try :
Redirect 301 /shop/products.html?search_limiter=full&keyword1=apple http://www.example.com/index.php?route=product/search&search=apple&description=true
but it did not work.
Is there any way ?
To rewrite on a querystring you have to use RewriteCond to match on the querystring first - you can then use that in the RewriteRule with a %N type match.
This will perform the rewrite you want (with any search term, not just "apple"):
RewriteEngine On
RewriteCond %{REQUEST_URI} shop/products.html
RewriteCond %{QUERY_STRING} search_limiter=full&keyword1=(\w+)
RewriteRule ^.*$ /index.php?route=product/search&search=%1&description=true [NC,L,R=301]
If you don't want to actually change the URL in the address bar, just the resource that's being loaded, leave R=301 (http 301 redirect) out of the flags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With