问题
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?
回答1:
I have the same issue, I got 404 error after setting URL rewrite rules in IIS. Finally I found that I need to open the Reverse Proxy by click following item.
回答2:
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>
来源:https://stackoverflow.com/questions/29321411/url-rewrite-in-iis-8-5-is-not-working-im-getting-404-instead