Question

I'm working on a real estate website. It would be ideal to have my client's featured properties have their own unique URL like:

www.realestatewebsite.com/featured/123-fake-st/

I'm constructing a CMS for my client so that they can add/delete featured properties in an admin backend, meaning that I need to write a program to automatically add the new URL for them based on the address they input in the database through the CMS.

I'm new to URL Rewrite. What would be the best way to go about this? I've considered using RewriterConfig in the web.config, but then I'm worried I would encounter problems writing a program that adds new rules to the web.config file. I thought about using a regex expression in the RewriterRule to find anything after /featured/ in the URL, but then if I'm just using the address in the LookFor then how would it know which property ID to use in the SendTo?

It would be ideal if I could just have a file put the address after "/featured/" into a string, look in the database for the address and retrieve the Property ID and then redirect the users that way.

As I said, I'm new to URL Rewriting and it would be great if someone could point me in the right direction.

Thanks!

-Aaron

Was it helpful?

Solution

There are different ways of doing this. Common to all solutions are the following:

  1. Set up a algorithm to create the URIs and store them in the database (changing space to - is a simple way to achieve this.
  2. Route the URI by making the address string into a parameter

Routing can be done a variety of ways.

If you have control of the server, or they have control of the server, you have the ability to set up IIS rewriting on the IIS instance on their server (good starter URI).

If this is hosted on an ISP, you may not have this option and have to use IIS rewriting and will have to use ASP.NET routing. Here is a good article to start with to undestand this. If you are using MVC, the routing is "built in".

OTHER TIPS

I would suggest using URL Rewrite Module for IIS7, look here: http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top