How would I redirect requests to a URL like

http://www.mydomain.com/foo.aspx 

to another URL like

http://www.mydomain.com/bar.aspx 

in IIS.

Can this be done in IIS 6.0 or 7.0?

link|improve this question
redirect or forward? – Campo Jun 8 '10 at 16:24
feedback

2 Answers

up vote 1 down vote accepted

If you have an existing foo.aspx file then you can set a Location header to redirect to the new file/URL:

<script runat="server">
private void Page_Load(object sender, System.EventArgs e) {
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","bar.aspx");
}
</script>

In IIS6, if the file exists, using the management snap-in, you can right-click to open the properties for the file and select to redirect to another location.

In IIS7, you can use the Rewrite module to capture the request and redirect it.

link|improve this answer
feedback

You can use URL Rewrite in IIS7.0.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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