Redirect http sang https dùng web.config trong IIS Asp.net

Thảo luận trong 'Lập trình web Asp.net' bắt đầu bởi admin, 27/7/18.

  1. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,883
    Đã được thích:
    1,193
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Để Redirect tư http sang https trong web asp.net sử dụng web.config bạn có thể dùng đoạn code dưới add vào file web.config của web để tự động chuyển hướng web sử dụng http sang https hiệu quả.
    Mã:
    <configuration>
    <!--Code của bạn... nếu có -->
      <system.webServer>
        <!--Code của bạn... nếu có -->
        <rewrite>
          <rules>
            <rule name="http to https" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                <add input="{HTTPS}" pattern="^OFF$" />
              </conditions>
              <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
            </rule>
          </rules>
        </rewrite>
      <!-- httpErrors có hoặc không có, itseovn bổ vô cho đủ bộ thôi hihi -->
        <httpErrors>
          <remove statusCode="403" subStatusCode="-1" />
          <remove statusCode="404" subStatusCode="-1" />
          <error statusCode="404" prefixLanguageFilePath="" path="https://itseovn.com/not-found.html" responseMode="Redirect" />
          <error statusCode="403" prefixLanguageFilePath="" path="https://itseovn.com/access-denied.html" responseMode="Redirect" />
        </httpErrors>
      </system.webServer>
    </configuration>
    
     
    Cảm ơn đã xem bài:

    Redirect http sang https dùng web.config trong IIS Asp.net

  2. vjetdung96
    Tham gia ngày:
    22/1/18
    Bài viết:
    126
    Đã được thích:
    5
    Điểm thành tích:
    18
    Giới tính:
    Nam
    asp.net giờ khó xin việc lắm ad ơi. mình thấy toàn tuyển về phần mềm chứ web hầu như không có tuyển nữa
     


Chủ để tương tự : Redirect http
Diễn đàn Tiêu đề Date
Lập trình web Asp.net Redirect https www to non-www using web.config asp.net iis 7 8.5 23/8/18
Lập trình web Asp.net Redirect 301 images old to new image in asp.net mvc c#? 25/3/23
Lập trình web Asp.net Redirect 301 from one website to another using web.config asp.net 29/10/21
Lập trình web Asp.net Redirect 301 trên Global.asax trong asp.net c# 100% thành công 28/2/20
Lập trình web Asp.net Redirect default.aspx to root home 301 in web.config asp.net c# 14/11/18