Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a set of rewrite rules (offhand, I would say around 40-50) for a given server. It's basically to handle and reroute mangled URLs so that bad links still go to where they're supposed to go.

I've come across an URL that is redirecting and I can't figure out which rewrite rule it is applying.

My background is Apache and in that case I'd simply enable a rewrite log and look at the logged output to figure out what was happening. Is there an equivalent way to do this in IIS?

bonus round

Any way for me to view & edit the rewrite rules in a text file rather than the GUI interface?

share|improve this question

Main Answer:

You can use the "Failed Request Tracing" feature to trace all kinds of requests in IIS 7.x (even rewritten ones). Here's a lovely article from learn.iis.net on just that.

Bonus round weigh-in:

Depending on the scope of the rewrite rules (configuration-wise), the rules are stored in either:

  • applicationHost.config - section: configuration/system.webServer/rewrite/globalRules
  • web.config - section: configuration/system.webServer/rewrite/rules

All IIS config files are basically XML files, so fire up your favorite XML editor and edit away. Beware that IIS 7.x (specifically the WAS service that picks up and validates configuration changes on-the-fly) is very sensitive to malformed XML, or configuration files that don't adhere to the IIS Schema, so be sure to back up the files before you edit them.

See the IIS.NET configuration reference for examples of built-in sections and properties, or head over to MSDN and check out the documentation

share|improve this answer
    
Thanks for this. However, I followed the exact steps on iis.net/learn/extensions/url-rewrite-module/… but no file is created in folder C:\inetpub\logs\FailedReqLogFiles...also no errors in the logfiles folder...what can this be? – Flo Nov 29 '15 at 22:07
    
@Flo Make sure the Failed Request Tracing feature is enabled both at the server-level and application-level, as described here: serverfault.com/questions/501482/… – Mathias R. Jessen Nov 29 '15 at 22:19
    
Thanks again. I had already enabled it on the site level. I now also enabled it on server level. But when I then go back to site level in IIS and click Failed Request Tracing module I get this error: Cannot add duplicate collection entry of type 'add' with unique attribute 'path' set to '*'. I also checked the web.config and I see that a node traceFailedRequests with <add path="*"> is added already...what can I do to fix this now? – Flo Nov 29 '15 at 22:34
    
@Flo remove all rules at server level, remove all rules at site-level, then recreate rule at server-level. You'll find that it's now also accessible at site-level – Mathias R. Jessen Nov 29 '15 at 22:35
    
Correct, I see it now at both server and site level. My web.config does not hold the trace node anymore (I deleted that when I was removing all earlier rules). But still I see no log file being created... – Flo Nov 29 '15 at 22:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.