简体   繁体   中英

Stripping end part of URL with .htaccess

Having a small issue and hoped to get a few suggestions on how to proceed.

I have a site that goes through a payment form using post and sends back a long url with a query I just want to get rid off. The form uses hidden fields and I am not sure why it sends back a query string... but trying to work with it.

This is a typical url that gets sent back is:

http://www.example.com/testsite/index.php?option=com_virtuemart&Itemid=200&lang=en&layout=details&order_number=VVF1019218&view=orders&charset=utf-8&clientAccnum=333333&clientSubacc=1111&initialPrice=30.00&initialPeriod=2&Code=840&customer_fname=Ky&customer_lname=Williams&email=kywilliams@gmail.com&zipcode=&country=US&order_pass=p_ro4VmHBS&state=IN&city=&address1=&context=65748571b98f45543245d0d7a9b&pmid=20&flexId=5647365-1fe6-43a0-9936-e9b0fc80c2aa&formDigest=83746543829384756

I would like the url to be turned into the following, with the rest of the url cut off. The order_number is dynamic so that changes at times.

http://www.example.com/testsite/index.php?option=com_virtuemart&Itemid=200&lang=en&layout=details&order_number=VVF1019218&view=orders

So when the url is sent to our server I would like .htaccess to cut off everything after view=orders . Is this possible? I have tried:

RewriteCond %{QUERY_STRING} "view=orders" [NC]
RewriteRule (.*)  /$1? [R=301,L] 

No luck so far. Hope to get pointed in the right direction. Thanks so much!

Try with:

RewriteCond %{QUERY_STRING} ^(.*view=orders) [NC]
RewriteRule (.*)  /$1?%1 [R=301,L]

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM