1

How can I use the URL Rewrite module in IIS to mimic a generic 404 handler?

It is easy enough to set up rewrite rules that match a specific pattern, but what I want to do is to set up a rewrite rule for any URL that does not match an existing file on disk (or a virtual folder).

I also need to know what the original URL was, so I can process it further.

For example, given the following request

http://host/foobar

If "foobar" resolves to an actual folder/file (or virtual folder), it should be handled as normal by IIS.

If "foobar" does not exist (ie the server would normally return a 404), the rewrite rule should kick in and forward to another URL, for example

http://host/my-404-handler?original-url=foobar

Is this possible using the URL Rewrite module? If not, how can I achieve it using other IIS tools/techniques?

Rewriter
  • 11
  • 1

0 Answers0