views:

419

answers:

1

Hi,

We're using IIS7 and ASP.NET 3.5.

We have updated our website with new pages. Now, there are many links on the internet pointing to our website, however many of those links are now broken due to a change in our directory structure for our new website.

I need to have a number of requests, 301 redirected to the "new page." Many of the old pages are simply directory URL's such as:

/services/softwaredevelopment

/products/geographicdata

/sitemap

/company/termsofuse

I have written some code in the Global.asax file to catch the url's, parse them out, and redirect them. However, when there is no file reference (.aspx), the URL's are not caught by my ASP.NET application.

It seems then, that these redirects need to be created in IIS7.

Now, the urls above are at a directory level (they are not directly requesting an actual .aspx page)... I can redirect a 'directory' request to another 'directory' by using virtual directories.... But I cant redirect a directory request to an actual .aspx file

Here are some of the types of redirects I need to make:

==========

Old: /services/softwaredevelopment

redirect to: /services/custom-software-development.aspx

============

Old: /sitemap

redirect to: /sitemap.aspx

============

Old: /company/termsofuse

redirect to: /company/termsofuse.aspx

=============

Old: /company/careers

redirect to: /company/careers.aspx

=============

Old: /services/

redirect to: /services/custom-software-development.aspx

=============

Can someone shed some light on how to accomplish this? Please let me know if you have any questions. Many thanks for your help.

Tim

A: 

One quick and dirty option is to create default.aspx redirect pages in the folders you have listed. For example, to handle /services/softwaredevelopment, create a file default.aspx at /services/softwaredevelopment/default.aspx with the following:

<%@ Page Language="C#" Inherits="System.Web.UI.Page" %>

<% Response.Redirect("/services/custom-software-development.aspx"); %>

This solution is only practical if there are only a few redirects, as it clutters your project with code files that do very little. A better solution for a large number of redirects is to use IIS 7's native URL rewriter.

gWiz