4

I have a website setup in IIS 6, let's say it's called http://www.this.com.

I have setup a redirection for this website to http://www.that.com which maintains the directory structure and query parameters as follows:

http://www.that.com$S$Q - using the option "The exact URL entered above"

This works great, whenever someone requests, for example:

http://www.this.com/subfolder/page.aspx?Id=1

then they end up at:

http://www.that.com/subfolder/page.aspx?Id=1

Now, I have one page, actually a handler, http://www.this.com/image.axd, which I do not want to redirect.

What is the syntax for that? I've read the Redirection Using Wildcards section here, but I can't work out how to do what seems to be something straight forward.

Note that image.axd is a handler so I can't just "right click" on it and set the redirection properties as it doesn't physically exist.

I also have a couple of other pages in subfolders which I do not want to redirect, for example:

http://www.this.com/subfolder/donotredirectthispage.aspx

Any help would be appreciated.

Edit: A couple of people have mentioned using ISAPI_Rewrite, for which I'm grateful, but I really don't want to introduce another complexity into the website configuration. IIS seems to imply I can acheive what I want using the ! and 0 through 9 variables.

Is it really not possible to do this using IIS?

My current workaround is to set the redirection properties on ALL folders and pages that I want to redirect except those I do not, but this is a management nightmare.

1
  • Hi Carl, I've just started working on this kind of redirect... Something I'm not sure about is where to enter this parameterized kind redirects. Are you doing this in IIS or directly in the metabase? Or perhaps in the web.config? I'm also using IIS6 Regards, Jacques Commented Sep 15, 2011 at 14:26

3 Answers 3

1

You could implement a custom error page for the page not found error (404) that does the redirection for you. You'd turn off the redirection in IIS. Build the logic for the redirection in your custom error page. Then configure your web site so that 404 errors redirect to your error page.

Sign up to request clarification or add additional context in comments.

1 Comment

Considering the updated question where he mentioned not liking some additional complexity, this really is the solution with the least impact. I implemented it myself and it's easy. Just leave your site as is and configure a custom 404 that loads _redirect.asp where you do response.redirect. Then remove all files you don't want to keep. Requests to those will be redirected using the custom 404.
0

If you can install software on your IIS server, I'd recommend using a tool to rewrite your request URLs.

For IIS 6.0 I've used ISAPI_Rewrite and it works really well. It's lightweight and very configurable. There's a "Lite" version available for free and will support your requirements.

You configure the program using a text file containing rules that match HTTP requests and then write actions to perform once a rule is matched. Your instance would probably require a general redirect rule (similar to the one in IIS) and rules for your exceptions.

Comments

0

You should look into the possibility of using a header rewrite module, for example ISAPI_rewrite. There is a free "lite" version available that is enough for your needs.

What this can do for you is the following: Before actual pages are executed on the server, the Request headers are rewritten (or HTTP 301/302 redirects are issued) based on a configurable set of rules. The underlying server sees the remaining requests as if the client really made them in that fashion.

The following rules would leave image.axd requests alone, while redirecting everything else.

# image.axd stays unchanged ("L" is the "last rule" flag)
RewriteCond Host: www.\this\.com
RewriteRule ^.*?\bimage\.axd\b.* $0 [L]

# all requests that have not been stopped by an earlier rule
# end up here ("RP" is the "permanent redirect" flag)
RewriteCond Host: www.\this\.com
RewriteRule .* http://www.that.com$0 [RP,L]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.