问题
I have a website which supports both HTTP and HTTPS (with a valid certificate) but unfortunally for internal issues with some external services, the HTTPS configuration is not ready yet to go in production.
I would like to redirect for now through IIS (web.config file) every https request to http.
I found in the official doc, the code to redirect from http to https but not the inverse. So I tried to convert it but IIS does not actually redirect:
<rule name="Redirect to HTTP" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
回答1:
Azure App Service websites supports the IIS URL rewrite module so what you are trying to do should work. I think the only thing you got wrong is the conditon, you are adding a condition for a Server Variable called HTTP, but there is no HTTP, only HTTPS which is either ON or OFF. See this for full list of IIS Server Variables. So, just flip it and instead of checking if HTTP is OFF (which doesn't exist and will never be true), check if HTTPS is ON
<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>
来源:https://stackoverflow.com/questions/42046083/redirect-from-https-to-http-in-azure-web-app-service