使用htaccess从查询字符串中删除%2F

时间:2016-09-06 09:25:14

标签: .htaccess redirect mod-rewrite url-rewriting

如何从下面重写的网址中的查询字符串中删除public class HomeController : Controller { public ActionResult Index() { var x = Newtonsoft.Json.JsonConvert.SerializeObject("sdfsdf"); #if DEBUG var y = Newtonsoft.Json.JsonConvert.SerializeObject("sfssesss"); #endif return View(); //put breakpoint here then into immediate window paste Newtonsoft.Json.JsonConvert.SerializeObject("sdfsdf"); and you should get the error. }

这是我的HTACCESS文件......

%2F

推荐网址...

RewriteCond %{HTTP_HOST} ^test\.example\.com$ [NC]
RewriteRule ^ http://www.example.com/?retailcentre=test$1%{REQUEST_URI} [QSA,NE,R=301,L]
上面的

然后重定向到此REWRITTEN URL ...

http://test.example.com/?utm_source=email&utm_medium=email&utm_campaign=022641ReservedEventCustomerEmail

正如您所看到的那样,http://www.example.com/?retailcentre=test%2F&utm_source=email&utm_medium=email&utm_campaign=022641ReservedEventCustomerEmail 之后需要删除%2F

1 个答案:

答案 0 :(得分:0)

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^test\.example\.com$ [NC]
RewriteRule ^ http://www.example.com%{REQUEST_URI}retailcentre=test [QSA,NE,R=301,L]