URL 重写 - 停止 https 以在 Azure (IIS) 上暂存 guid url
我在 Azure 应用程序的 web.config 中有此重写规则,以确保用户始终使用 HTTPS:
<rule name="HTTP to HTTPS redirect"
stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}"
pattern="off" />
<add input="{REQUEST_URI}"
pattern="^clientaccesspolicy\.xml$"
negate="true" />
<add input="{REQUEST_URI}"
pattern="^crossdomain\.xml$"
negate="true" />
</conditions>
<action type="Redirect"
redirectType="Found"
url="https://{HTTP_HOST}/{R:1}" />
</rule>
它工作正常。用户总是使用我们公司 URL 的子域访问该网站,并且我们有一个通配符证书。
但是当应用程序暂存时,我想在没有 https 的情况下使用它(但仍然不允许 http 访问标准 cloudapp 子域)。 例如,这可以通过 http:
http://f9eccd6a9a044270b5ce97ae614c9ee1.cloudapp.net
但这不会:
< a href="http://myazuresubdomain.cloudapp.net" rel="nofollow">http://myazuresubdomain.cloudapp.net
我的正则表达式技能很少,我的网址重写技能仅限于从 SO 复制上述内容。那么有人可以帮助我制定有助于我实现上述目标的规则吗?也许是 .cloudapp.net 恰好包含 32 个字符的 url 的否定?
谢谢马克
I have this rewrite rule in web.config on our Azure app to ensure the users always use HTTPS:
<rule name="HTTP to HTTPS redirect"
stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}"
pattern="off" />
<add input="{REQUEST_URI}"
pattern="^clientaccesspolicy\.xml$"
negate="true" />
<add input="{REQUEST_URI}"
pattern="^crossdomain\.xml$"
negate="true" />
</conditions>
<action type="Redirect"
redirectType="Found"
url="https://{HTTP_HOST}/{R:1}" />
</rule>
It works fine. The users always hit the site using a subdomain of our company URL and we have a wildcard certificate.
But when the app is staging I would like to use it without https (but still not allow http acccess to the standard cloudapp subdomain).
so for example this would work over http:
http://f9eccd6a9a044270b5ce97ae614c9ee1.cloudapp.net
But this wouldn't:
http://myazuresubdomain.cloudapp.net
My Regex skills are minimal and my url rewrite skils are limited to copying the above from SO. So could someone help me with the rule that will help me acheive the above? Perhaps a negate for a url that has exactly 32 chracters then .cloudapp.net?
Thanks
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下规则应该符合您的要求。由于“stopProcessing”属性,将其放在第一位将跳过 https 重定向。
The following rule should match what you're after. Placing it first will skip the https redirect due to the 'stopProcessing' attribute.