I have an application ASP.Net, Web api with c# , that used https and I want the js, css files and images to be sent with http. I try different thinks but it didn't work. I've tried this:
<rewrite>
<rules>
<rule name="Redirect Image to HTTP">
<match url=".*\.(gif|jpg|jpeg|png|css|js)$"/>
<action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="SeeOther"/>
</rules>
</rewrite>
What am I doing wrong?
Try this
<rules>
<rule name="Redirect Image to HTTP">
<match url=".*\.(gif|jpg|jpeg|png|css|js)$"/>
<action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="Found"/>
</rules>
Probably you should specify HTTPS as condition:
<rewrite>
<rules>
<rule name="Redirect Image to HTTP">
<match url=".*\.(gif|jpg|jpeg|png|css|js)$"/>
<conditions>
<add input="{HTTPS}" pattern="ON" />
</conditions>
<action type="Redirect" url="http://{SERVER_NAME}/{R:1}" redirectType="SeeOther"/>
</rules>
</rewrite>
BTW, it's better to use .+
rather than .*
in your regexp.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.