文章内容
2017/9/27 17:45:52,作 者: 黄兵
Web.config URL Rewrites - HTTPS and Non-WWW
I need the URLs to redirect from:
- pdf-lib.org ---> https://testing.com
- www.pdf-lib.org ---> https://pdf-lib.org
- www.pdf-lib.org/Home/Details/1136 ---> https://pdf-lib.org/Home/Details/1136
解决方案:
Was my own issue - there was no DNS for the www
, therefore the redirect wouldn't resolve on it's own.
Code used:
<rule name="Redirect to HTTPS" stopProcessing="true"> <match url="(.*)"/> <conditions> <add input="{HTTPS}" pattern="^OFF$"/> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent"/> </rule> <rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="true"> <match url="*" /> <conditions> <add input="{CACHE_URL}" pattern="*://www.*" /> </conditions> <action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent" /> </rule>
评论列表