2017-10-20 119 views
0

有一个小问题,希望得到一些关于如何继续的建议。用.htaccess剥离URL的末尾部分

我有一个网站会通过付款表单使用信息并发回一个长的网址,我只想删除一个查询。该表单使用隐藏的字段,我不知道为什么它发回一个查询字符串...但试图与它一起工作。

这是被送回是一个典型的网址:

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 protected]&zipcode=&country=US&order_pass=p_ro4VmHBS&state=IN&city=&address1=&context=65748571b98f45543245d0d7a9b&pmid=20&flexId=5647365-1fe6-43a0-9936-e9b0fc80c2aa&formDigest=83746543829384756

我想链接直接变成下文中,切断网址的其余部分。 order_number是动态的,所以有时候会发生变化。

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

因此,当URL发送到我们的服务器,我想的.htaccess view=orders后切断一切。这可能吗?我曾尝试过:

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

到目前为止没有运气。希望指出正确的方向。非常感谢!

+0

因为你无法控制他们送什么网址-PARAMS你需要重定向,而不是重写。 – Jeff

+0

谢谢。我将研究重定向而不是尝试重写,并看看我能否使用它。也许我可以重定向到相同的URL与一些网址去掉。所有其他信息是我们试图确保网站用户看不到的帐户信息。再次感谢! – user2343465

+0

看看你已经尝试过了,因为'''''''view = orders'附近不行。他们不应该在那里。但是,这仍然只会给你'http:// www.example.com/testsite/index.php' – Lag

回答

0

与尝试:

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