18/02/2022

Redirect http to https trên web.config

Thông thường, rule redirect được khai báo trong file web.config nằm trong thư mục gốc website của. Nếu redirect không hoạt động, hay kiểm tra web.config có tồn tại không và rule redirect có đúng quy tắc không? Bài viết sau Nhân Hòa sẽ hướng dẫn Redirect http to https

Dưới đây là rule redirect mẫu:

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”HTTPS force” enabled=”true” stopProcessing=”true”>
<match url=”(.*)” />
<conditions>
<add input=”{HTTPS}” pattern=”^OFF$” />
</conditions>
<action type=”Redirect” url=”https://{HTTP_HOST}{REQUEST_URI}” redirectType=”Permanent” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Chúc các bạn thành công!