IIS 8.5 中的 URL 重写不起作用,我得到的是 404 [英] URL rewrite in IIS 8.5 is not working I'm getting 404 instead

查看:59
本文介绍了IIS 8.5 中的 URL 重写不起作用,我得到的是 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的 IIS 上配置了一个重写规则,但它似乎从未被触发过我已经为此工作了几个小时但没有任何运气这是我在 web 配置中的规则应用程序:

 <规则><rule name="重写友好的 url 到快照" stopProcessing="true"><match url="/(localhost:2934)\/trabajos\/([\w-]+)\/([\w-|\-]+)"/><action type="Rewrite" url="\/snapshots/{R:2}.html" logRewrittenUrl="true"/></规则></规则></rewrite>

我的网址如下:

我没有在日志中收到任何错误或文件文件夹.例如:C:\inetpub\logs\FailedReqLogFiles

我收到了 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 42015-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

有什么想法吗?

解决方案

好像我遇到了同样的问题 问题 我更改了 url 模式并删除了路径开头的斜杠.

这是有效的规则:

<规则><rule name="重写友好的 url 到快照" stopProcessing="true"><match url="trabajos\/([\w-]+)\/([\w-|\-]+)"/><action type="Rewrite" url="snapshots/{R:1}.html" logRewrittenUrl="true"/></规则></规则></rewrite>

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:

    <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 '

and I want to rewrite as:

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

this is the result I get from testing the pattern in the 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. ex: C:\inetpub\logs\FailedReqLogFiles

I'm getting a 404 error instead and it's logged like this:

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?

解决方案

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>

这篇关于IIS 8.5 中的 URL 重写不起作用,我得到的是 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆