简体   繁体   English

IIS 8.5中的URL重写无法正常工作,我却得到404

[英]URL rewrite in IIS 8.5 is not working I'm getting 404 instead

Hi I've configured a rewrite rule on my IIS but it seems like it never gets fired I've been working on this for several hours without any luck this is my rule in the web config of the appplication: 嗨,我已经在IIS上配置了重写规则,但似乎从来没有被解雇过,我已经花了好几个小时没有任何运气,这是我在应用程序的Web配置中的规则:

    <rewrite>
      <rules>
        <rule name="Rewrite frienly url to snapshot" stopProcessing="true">
          <match url="/(localhost:2934)\/trabajos\/([\w-]+)\/([\w-|\-]+)" />
          <action type="Rewrite" url="\/snapshots/{R:2}.html" logRewrittenUrl="true" />
        </rule>
      </rules>
    </rewrite>

my URL is the following: 我的网址如下:

http://localhost:2934/trabajos/3ba2a9e4/some-cool-title ' http:// localhost:2934 / trabajos / 3ba2a9e4 / some-cool-title '

and I want to rewrite as: 我想重写为:

http://localhost:2934/snapshots/3ba2a9e4.html http:// localhost:2934 / snapshots / 3ba2a9e4.html

this is the result I get from testing the pattern in the IIS: 这是我通过在IIS中测试模式得到的结果:

测试URL重写IIS

to me seems to be ok 对我来说似乎还可以

but when testing the URL in the browser, I feel like the rule never gets fired, in fact, I've configured to trace failed request like this tutorial and I don't get any error or file in the logs folder. 但是在浏览器中测试URL时,我觉得规则永远不会触发,实际上,我已经配置为跟踪失败的请求(如本教程),并且在logs文件夹中没有任何错误或文件。 ex: C:\\inetpub\\logs\\FailedReqLogFiles 例如:C:\\ inetpub \\ logs \\ FailedReqLogFiles

I'm getting a 404 error instead and it's logged like this: 我收到404错误,它的记录如下:

2015-03-28 18:56:11 ::1 GET /trabajos/3ba2a9e4/some-cool-tile - 2934 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/42.0.2311.60+Safari/537.36 - 404 0 2 4
2015-03-28 18:56:15 ::1 GET /trabajos/3ba2a9e4/some-cool-title - 2934 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/42.0.2311.60+Safari/537.36 - 404 0 2 2

any ideas? 有任何想法吗?

I have the same issue, I got 404 error after setting URL rewrite rules in IIS. 我有同样的问题,在IIS中设置URL重写规则后出现404错误。 Finally I found that I need to open the Reverse Proxy by click following item. 最后,我发现我需要通过单击以下项目来打开反向代理。

在此处输入图片说明

Seems like I had the same issue as this question I changed the url pattern and removed the slash at the begening of the path. 似乎我有与此问题相同的问题,因此我更改了网址格式并在开始生成路径时删除了斜线。

this is rule that works: 这是有效的规则:

<rewrite>
      <rules>
        <rule name="Rewrite frienly url to snapshot" stopProcessing="true">
          <match url="trabajos\/([\w-]+)\/([\w-|\-]+)" />
          <action type="Rewrite" url="snapshots/{R:1}.html" logRewrittenUrl="true" />
        </rule>
      </rules>
    </rewrite>

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

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