Asp.net
重寫規則錯誤:HTTP 錯誤 500.50 - URL 重寫模組錯誤。無法展開表達式“https://abc.com/{R:1}”
每當有人通過 HTTP 協議發出請求時,我都會重寫 url 以使其成為 HTTPS。這是 web.config 中的程式碼:
<rule name="Imported Rule 1-1" enabled="true" stopProcessing="true"> <match url="^(?!https://).*" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{SERVER_PORT}" pattern="80" ignoreCase="false" /> </conditions> <action type="Rewrite" url="https://abc.com/{R:1}" /> </rule>但是,當我在 http:// 上瀏覽時,我得到 IIS 錯誤
HTTP 錯誤 500.50 - URL 重寫模組錯誤。表達式
"https://abc.com/{R:1}"無法展開。我該如何解決這個問題?我完全糊塗了。
匹配是從零開始的。
<action type="Rewrite" url="https://abc.com/{R:1}" />行不通,因為你只有一場比賽。你需要:
<action type="Rewrite" url="https://abc.com/{R:0}" />此外,這也行不通,因為您只能在站點根目錄下的路徑上進行匹配。
<match url="^(?!https://).*" ignoreCase="false" />看起來您正在檢查 ssl。試試這個:
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTPS}" pattern="^OFF$" /> </conditions>