本文介绍了在IIS 7.5上重写URL的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用IIS 7.5的URL重写模块将所有HTTP请求重定向到ASP.NET网站的HTTPS.该网站目前可以正常运行,但是会强制用户在地址栏中键入https://.

I'm trying to use the URL Rewrite module for IIS 7.5 to redirect all HTTP requests to HTTPS for my ASP.NET website. The site works fine at the moment but forces the user to type the https:// in the address bar.

我遵循了本文中的说明.一切似乎都没问题:我已经尝试将规则放在web.config中,并按需显示在UI中;我也做了相反的操作,当我使用UI添加规则时,可以在web.config中看到更改.我的网站未选中RequireSSL.不幸的是,当我尝试通过http://进入该网站时,我仍然只得到404.

I followed the instructions in this article. Everything seems to be fine: I've tried putting the rule in the web.config and it shows up in the UI as it should; I've also done the reverse and can see the changes in the web.config when I use the UI to add the rule. I have RequireSSL unchecked for the site. Unfortunately I still just get a 404 when I try to hit the site via http://.

我尝试了几种不同的操作网址,包括{HTTP_HOST}/{R:1}和下面显示的网址..没有任何效果.

I've tried a few different action urls including {HTTP_HOST}/{R:1} and the one shown below.. nothing works.

<system.webServer>
  <rewrite>
    <rules>
      <rule name="Redirect to https" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}"
         redirectType="SeeOther" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

我对此很陌生,在这一点上非常沮丧.似乎这样应该容易得多.任何建议,将不胜感激,谢谢..

I'm fairly new to this and pretty frustrated at this point. Seems like this should be a lot easier. Any advice would be appreciated, thanks..

由于ServerFault坐了一会儿而没有答案,因此正在重新发布.

Reposting from ServerFault as it's been sitting unanswered for a while.

推荐答案

您实际上对HTTP 80端口具有绑定吗?听起来好像您没有它(只有HTTPS).

Do you actually have binding for HTTP 80 port? Sounds like you do not have it (only HTTPS).

我要问的原因是带引号的文本是确切消息,我将查看是否请求IIS域未知(当未定义全部捕获时)或域未绑定到请求的端口.

The reason I'm asking is the quoted text is the exact message that I would see if I request unknown to IIS domain (when there is no catch-all defined) or domain is not bound to the requested port.

这篇关于在IIS 7.5上重写URL的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 02:51