short URL that links to a long URL

Posted on 2005-04-06
Last Modified: 2008-02-01

I have seen sites that use following syntax to link to topic areas:

How is that short URL linked if I have a longlink saved in a DB?

I know how to link it using a the response.riderect but that would change the syntax to following: -> this NOT how I woant to do it.

Any help is apretiated
thank you
Question by:LotharGores
    LVL 9

    Expert Comment

    Create a subfolder under wwwroot and name it 2355613.
    In that directory create a web page named default.html or index.html or default.asp or index.asp - whatever is configured as the default in IIS.

    When you link to it will load the first default file found.
    LVL 2

    Author Comment

    I thought about that, but that would mean if I had 10000 links that I have to create 10000 subfolders!

    is this the only way this would work?
    LVL 9

    Expert Comment

    EEEEWWWW!  Could be.

    The only thing else I can think of is if IIS will automatically assume the ".ASP" or ".HTM" extension to a file name.  You could just create a page named 2355613 in wwwroot.  Would require 10000 pages, though and I might just be hallucinating here.  Otherwize you need to pass the 2355613 value as a variable (

    Anyone else have an idea?
    LVL 12

    Expert Comment

    Personally, I'd pass the linkID in the string like dana suggested.  There's really no good reason for trying to use the subfolder name to build the link if you have a data driven website.
    LVL 18

    Expert Comment

    Yeah, combine those ideas, making "2366513" the value being passed:

    In other words:
    which would be similar to:

    you'd access the querystring value without naming a variable...

    strMyVariable = Request.Querystring
    LVL 2

    Expert Comment

    Letz conside 2366513 is a primary key of some table where that table will have primary key and long link.
    Now if user access user site, you can get the long url from the primary key they entered in the URL.
    You can follow the same logic..

    Happy Programming!!!
    LVL 9

    Accepted Solution

    You can create a custom 404 page. This could something like the following:


    Dim strURL, _
          arrURI, _
          strRequestedLink, _
    Dim objFSO, _
          objFolder, _

    strURL = Request.ServerVariables("HTTP_URL")
    strURL = Right(strURL, (Len(strURL) - (Instr(strURL, chr(59)))))

    arrURI = Split(strURL, "/")

    strRequestedLink = arrURI(1)

    Response.Redirect("" & strRequestedLink)

    You could add some additional checking in there to determine if the 404 is actually beging used in your short-link format, or if it's a genuine page failure...
    LVL 15

    Assisted Solution

    What you're asking for would often be called 'URL masking'. There are two ways to do this.

    - A custom 404 error page (as AlfaNoMore) suggested. This is easy to implement and requires only a small amount of config in IIS.
    - An ISAPI filter in IIS. This is definitely the best way (most reliable method, best performance) but requires more fiddling in IIS and you'll probably have to spend money to buy a product to do this. Do a search on Google and see what turns up.
    LVL 18

    Expert Comment

    Any update on this?
    LVL 15

    Expert Comment


    Similar question here with some good suggestions:
    LVL 6

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
    I will leave the following recommendation for this question in the Cleanup topic area:
    Split: AlfaNoMore & deighc

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    EE Cleanup Volunteer

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now