url rewriting - IIS Rewrite Rule in web.config to redirect HTTPS requests to HTTP -
i need redirect https requests http, example, if visits https://www.example.com/another-page/ http://www.example.com/another-page/
i have following rewrite rule in web.config right now, it's not working correctly. it's redirecting https://www.example.com/another-page/ https://www.example.com/, root of site, instead want redirect stay in same url , rewrite https http.
<rule name="redirect http" stopprocessing="true"> <match url="(.*)" /> <conditions> <add input="{r:1}" pattern="^onepage/(.*)$" negate="true" /> <add input="{https}" pattern="^on$" /> </conditions> <action type="redirect" url="http://{http_host}/{r:0}" redirecttype="permanent" /> </rule>
any on changing above rule changes https http, keeps full url visited appreciated!
i set rule, cleaned little, , worked; isn't answering new.
suggestion: remove onepage
input condition testing, cheesmacfly suggested in question comment.
also, try changing action {r:1}
instead of {r:0}
. shouldn't matter in case, using 1 , up, match specific capturing group. r:0 means entire matched string, confuses me little.
<rule name="redirect http" stopprocessing="true"> <match url="(.*)" /> <conditions> <add input="{https}" pattern="^on$" /> </conditions> <action type="redirect" url="http://{http_host}/{r:1}" redirecttype="permanent" /> </rule>
one possibility browser has cached previous attempt of rules. when redirecttype permanent, , you're still developing or testing, browser caches previous rule. clear browser cache, and/or remove permanent, and/or browse in incognito mode. when done testing, change permanent. see number 2 , 3 in answer: https://stackoverflow.com/a/9204355/292060
Comments
Post a Comment