0

We've got a brochure-style website with links at the top such as "Home", "About", "Contact", all that stuff... typical boilerplate site. My boss just asked if it would be possible to redirect all traffic so that if (for example) somebody goes to www.mywebsite.com/contact it would redirect to www.mywebsite.com/contact.aspx instead of generating a 404 page.

My gut thought was to create a folder with a single webpage, whose sole purpose is to response.redirect to the appropriate aspx page (e.g. contact/default.aspx routes to contact.aspx, etc). However that would work in the short-term, but it's neither an elegant nor a long-lasting solution.

Is there a simple way to handle this in a webforms app?

Don Quixote
  • 235
  • 1
  • 5
  • 15
  • I think you are looking for something like this, http://stackoverflow.com/questions/2161413/implementing-a-custom-error-page-on-an-asp-net-website Please implement error404 page and within that page, just write logic to redirect page. – INDIA IT TECH Mar 24 '16 at 09:23

1 Answers1

0

I found the answer, which lies in Microsoft's URL Rewrite Module. I was able to make a mapping table that accommodated my needs.

  1. Install the module
  2. Choose your site in IIS and then double-click the "URL Rewrite" module
  3. Choose "View Rewrite Maps..." from the actions panel on the right
  4. Choose "Add Rewrite Map..."
  5. For each page you want to redirect/rewrite, choose "Add Mapping Entry", enter the original value (e.g. "/SomeFolder") and the new value (e.g. "/SomePage.aspx")
  6. Go back to the Rules page, choose "Add Rule(s)..." on the right
  7. Choose "Rule with rewrite map"
  8. For the rule action, choose "Rewrite" if you want the user to see "mysite.com/SomeFolder" in the address bar... choose "Redirect" if you want the user to see "mysite.com/SomePage.aspx" in the address bar
  9. Select the rewrite map you created
  10. The site should now redirect/rewrite from the old value to the new value.
Don Quixote
  • 235
  • 1
  • 5
  • 15