В свете новой моды от Google по переводу всех сайтов на HTTPS небольшая заметка как с помощью модуля URL Rewrite на IIS 7 и 8 осуществить редирект с HTTP адресов на HTTPS.
Ниже пример файла web.config:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Redirect to HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="^OFF$" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" /> </rule> </rules> </rewrite> </system.webServer> </configuration> |
и при необходимости наоборот, с HTTPS на НТТP:
1 2 3 4 5 6 7 |
<rule name="Redirect to HTTP" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="^ON$" /> </conditions> <action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" /> </rule> |
И как обычно, ссылки по теме: