[英]How to remove querystring from a url via web.config
I need 301 redirect for all urls like 我需要所有网址的301重定向,例如
xyz.com/searchitems?key1=val1&key2=val2 to be like
xyz.com/searchitems?key1=val1&key2=val2就像
xyz.com/searchitems
xyz.com/searchitems
ie I want query string to be removed from URL. 即我想从URL中删除查询字符串。 I have written this so far in my
web.config
到目前为止,我已经在我的
web.config
编写了此内容
<rewrite>
<rules>
<rule name="Rewrite to searchitems">
<match url="^searchitems?$" />
<conditions>
<add input="{QUERY_STRING}" pattern="(.*)" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:0}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
but it is making redirect loop 但它使重定向循环
Edit: 编辑:
I wat the querystring to be removed just for this url "xyz.com/searchitems" and not for all urls. 我只是为这个URL“ xyz.com/searchitems”而不是所有URL删除了querystring。 There can be any number of query string params in urls.
网址中可以有任意数量的查询字符串参数。
Try this: 尝试这个:
<rewrite>
<rules>
<rule name="Custom rule" stopProcessing="true">
<match url="^searchitems" />
<conditions>
<add input="{QUERY_STRING}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="/searchitems" appendQueryString="false" />
</rule>
</rules>
</rewrite>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.