URL重写改变查询字符串的情况下 [英] URL Rewrite to change querystring case
问题描述
我期待在设置我的web.config的URL重写规则,将修改以下网址:
/detail.aspx?aID=164&mode=t
要(见援助的情况下
)
/detail.aspx?aid=164&mode=t
请任何人能帮助我吗?唯一的其他东西在这里提到的是,如果在年底也不论什么样的顺序援助没有
参数出现在查询字符串。模式
参数规则应该仍然工作
修改1
我发现这个指南,改写整个URL为小写。这对我的工作只接受的解决方案似乎忽略的查询字符串值。
编辑2
我现在用下列条件时,发现大写字符发出301重定向。接受的答案解决了原来的问题,但这种解决方案的工作完整的URI,域,路径和查询字符串上。
'301重定向大写URIS
昏暗fullUri作为字符串= Request.Url.AbsoluteUri
如果fullUri.Any(功能(C)Char.IsUpper(C))然后,
的Response.RedirectPermanent(fullUri.ToLower)
万一
编辑:
你说得对,没有意识到这是同一页。
您需要添加另一个条件。
<规则名称=URL下启用=真stopProcessing =真>
<匹配URL =^(detail.aspx?)(。*)/>
<条件trackAllCaptures =真正的>
<添加输入={} QUERY_STRING模式= /&GT(*);
<添加输入={} QUERY_STRING模式=([A-Z] +)IGNORECASE =FALSE/>
&所述; /条件>
<作用TYPE =重定向URL ={detail.aspx ToLower将:{C:1}}?appendQueryString =FALSE/>
< /规则>
例如:
/detail.aspx?aID=164&mode=t
转换成
/detail.aspx?aid=164&mode=t
和第二,因为规则/detail.aspx?aid=164&mode=t被忽略。
I am looking to setup a URL rewrite rule in my web.config that will modify the following URL:
/detail.aspx?aID=164&mode=t
To (see case of aid
):
/detail.aspx?aid=164&mode=t
Please can anyone assist me with this? The only other thing to mention here is that the rule should still work if there is no mode
parameter at the end and irrespective of what order the aid
parameter appears in the querystring.
EDIT 1
I found this guide which rewrites the whole URL to lowercase. This would work for me only the accepted solution seems to ignore the query string values.
How to display URL in lower case?
EDIT 2
I'm now using the following to issue a 301 redirect when uppercase characters are found. the accepted answer addresses the original question but this solution works on the full URI, domain, path and querystring.
'301 REDIRECT ON UPPERCASE URIS
Dim fullUri As String = Request.Url.AbsoluteUri
If fullUri.Any(Function(c) Char.IsUpper(c)) Then
Response.RedirectPermanent(fullUri.ToLower)
End If
EDIT: You are right, did not realize it was same page. You need to add another condition.
<rule name="URL Lower" enabled="true" stopProcessing="true">
<match url="^(detail.aspx?)(.*)" />
<conditions trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="(.*)" />
<add input="{QUERY_STRING}" pattern="([A-Z]+)" ignoreCase="false" />
</conditions>
<action type="Redirect" url="detail.aspx?{ToLower:{C:1}}" appendQueryString="false" />
</rule>
Examples:
/detail.aspx?aID=164&mode=t converts to /detail.aspx?aid=164&mode=t
and /detail.aspx?aid=164&mode=t is ignored because of second rule.
这篇关于URL重写改变查询字符串的情况下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!