Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
redirect or forward? –  Campo Jun 8 '10 at 16:24
add comment

2 Answers

up vote 2 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.

share|improve this answer
add comment

You can use URL Rewrite in IIS7.0.

share|improve this answer
add comment

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.