asp.net - IIS URL 重写中小写 WWW HTTP 的单一规则

标签 asp.net iis url-rewriting

我正在尝试创建一个单一重写规则(以避免多个 301 重定向),该规则会将所有请求转换为 https、小写、www 前缀。

所以,http://example.com/Page将是 https://www.example.com/page - 全部在一个规则内。

我该怎么做?

最佳答案

<rule name="All in one URL" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAny">
        <add input="{HTTPS}" pattern="off" />
        <add input="{REQUEST_URI}" pattern="[A-Z]" ignoreCase="false" />
        <add input="{HTTP_HOST}" pattern="^www\." negate="true" />
     </conditions>
     <action type="Redirect" url="https://www.example.com:35077{ToLower:{URL}}" />
</rule>

这条规则可以做到这一点:

  • 小写网址
  • 强制使用 HTTPS
  • 如有必要,请在前面加上 www

关于asp.net - IIS URL 重写中小写 WWW HTTP 的单一规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31791927/

相关文章:

c# - 将数据从 DataTable 插入到 Excel 工作表中

asp.net - IIS/ASP.NET 故意响应同时请求比单个请求慢?

IIS 8.5 : Virtual Account for App Pool (IIS AppPool\{Application Pool Name} is not available

mod-rewrite - 添加文件的斜杠和剪切扩展名(nginx 规则)

c# - 数组 : "Index was outside the bounds of the array"

c# - Asp.net MVC 模型绑定(bind)派生类

C# dotnet web 应用程序 : Dll's xml config file is lost when Publishing

flash - 深层链接 URL 问题

php - 如何制定从 id 到 name 的 htaccess 规则

c# - ListView 中的 FindControl (ImageButton)