简体   繁体   English

IIS 7.5上的URL重写问题

[英]Problem with URL rewrite on IIS 7.5

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. 我正在尝试使用IIS 7.5的URL重写模块将所有HTTP请求重定向到ASP.NET网站的HTTPS。 The site works fine at the moment but forces the user to type the https:// in the address bar. 该站点目前可以正常工作,但是会强制用户在地址栏中键入https://。

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; 一切似乎都很好:我已经尝试过将规则放在web.config中,并按需显示在UI中; I've also done the reverse and can see the changes in the web.config when I use the UI to add the rule. 我也做了相反的操作,当我使用UI添加规则时,可以在web.config中看到更改。 I have RequireSSL unchecked for the site. 我的网站未选中RequireSSL。 Unfortunately I still just get a 404 when I try to hit the site via http://. 不幸的是,当我尝试通过http://进入该站点时,我仍然只能得到404。

I've tried a few different action urls including {HTTP_HOST}/{R:1} and the one shown below.. nothing works. 我尝试了几种不同的操作URL,包括{HTTP_HOST} / {R:1}以及下面显示的URL。

<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.. 任何建议,将不胜感激,谢谢..

Reposting from ServerFault as it's been sitting unanswered for a while. 从ServerFault重新发布,因为它已经坐了一会儿了。

HTTP Error 404. The requested resource is not found HTTP错误404。找不到请求的资源

Do you actually have binding for HTTP 80 port? 您实际上有HTTP 80端口绑定吗? Sounds like you do not have it (only HTTPS). 听起来好像您没有它(仅HTTPS)。

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域未知(当未定义全部捕获时)或域未绑定到请求的端口,我将看到该消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM