stuartjay
stuartjay

Reputation: 47

Thinking of a way to map a short url structure to a long url structure

this is my first question here so apologies for my hilarious ignorance.

I have a website in C# that currently formats its pages using a mixture of root folders and a query string. Each page has a unique ID that is dependent on one of the root folders.

For example: www.mywebsite.com/files/cats/index.aspx?p=100000 and www.mywebsite.com/files/ducks/index.aspx?p=100001, where the P value is the unique integer, www.mywebsite.com/files/cats/index.aspx?p=100001 would not work.

What I want to do is to use a short URL that would map to these values, without necessarily using a database.

For instance, going to http://myw.eb/cat/100000 would map to http://www.mywebsite.com/files/cats/index.aspx?p=100000.

Is there any way that this would be possible or am I better off using another method? I don't like the idea of hashing the unique IDs as I see it as doubling up.

Any help would be incredibly appreciated.

Upvotes: 1

Views: 186

Answers (3)

Jim Mischel
Jim Mischel

Reputation: 134055

Is it always a straight mapping? That is, will http://myw.eb/<type>/<id> always map to http://myw.eb/files/<type>s/index.aspx?p=<id>, where is "duck" or "cat" or whatever, and is the integer?

If so, then you can create a simple script that parses the short url and does the necessary replacements to generate the long url. No database required. I don't know if that's supported by the URL Rewrite Module, that fardjad mentioned, but I suspect it is.

Upvotes: 0

Alexei Levenkov
Alexei Levenkov

Reputation: 100555

ASP.Net MVC routing is another approach to path portion of the Url (if you are willing to do slightly more work).

Side note: getting short and useful domain name maybe hard, fixing path portion of the path is easy.

Upvotes: 0

fardjad
fardjad

Reputation: 20404

You can use URL Rewrite Module in IIS7.

in IIS6 you can use ISAPIRewrite.

Upvotes: 3

Related Questions