[英]IIS Redirect Regex doesn't work with a space - %20 in URL
所以我有一個簡單的問題但不知何故似乎沒有用。 我有一個網址http://www.domain.com/%20#axzz2ZX4J0KAS
,我想重定向到http://www.domain.com/page-name.htm
。 我在IIS URL Rewrite / web.config中嘗試了很多組合,它們似乎都在測試模式對話框中工作,但在瀏覽器中都不起作用。
1。
<rule name="Redirect%20InHomePage" enabled="true" stopProcessing="true">
<match url="^(.+)domain\.com/(\s|%20)(.+)" ignoreCase="true" />
<action type="Redirect" url="http://www.domain.com/page-name.htm" />
</rule>
2。
<match url="(.+)/%20(.+)" ignoreCase="true" />
3。
<match url="(.+)domain.com/ (.+)" ignoreCase="true" />
4。
<match url="(.+)domain.com/(\s|%20)(.+)" ignoreCase="true" />
正如您所看到的,我嘗試了以上所有模式,它們在“測試模式”對話框中都能正常工作,但是當我瀏覽URL時,它總是將%20轉換為空格,而規則不適用於重定向。
如果有人知道我錯過了什么,請幫助我解決這個簡單但尚未解決的問題。
不要在您的匹配網址中包含域名。
如果你想要處理你的網址中是否有跟蹤代碼,那么你可能想要使用這樣的東西:
<rule name="RedirectSpaceInHomePage" stopProcessing="true">
<match url="^\s(#\.*)?$" />
<action type="Redirect" url="page-name.htm" />
</rule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.