1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

ASP dynamic 301 redirect based on Product ID

Discussion in 'C#' started by rumblepup, Apr 26, 2007.

  1. #1
    Hey all. I got a really good response from tgo on how to implement a series of 301 redirects using asp,

    http://forums.digitalpoint.com/showthread.php?t=238610

    and he gave me this bit of code:

    However, on that thread, I mentioned that all the product id's would change when I migrated the database from one to another. During that exercise, I found a way to keep my original product UID's (ID's) so there is one constant between the to apps.

    /prodView.asp?idproduct=55

    should point to

    /detail.aspx?=ID55

    So, is there a way for me to do this with just a couple of lines of code instead of an if then statement for each product ID

    My logic is this

    IF
    /prodView.asp?idproduct=<THE PRODUCT ID NUMBER>
    THEN
    response.redirect
    /detail.aspx?=<THE SAME PRODUCT ID>


    Any help please?
     
    rumblepup, Apr 26, 2007 IP
  2. solution2u

    solution2u Peon

    Messages:
    252
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <%
    If IsNumeric(Request.QueryString("idproduct")) Then ' Or you can put Request.QueryString("idproduct") <> ""
    Response.redirect("/detail.aspx?=" & Request.QueryString("idproduct"))
    End If
    %>

    Note that this is not 301 redirect. For 301 redirect, please use Response.AddHeader

    Hope it helps ;)
     
    solution2u, Apr 27, 2007 IP
  3. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Have you considered using Helicon's isapi rewrite filter to do this dynamically rather than coding it in the site? If you do, you can add seo to the equation by using text names for the products and an 'htm' extension. I do this on my site and rather than have /content.asp?id=112, I have urls like high output alternator. I use the tilde because I have hyphens in the file names.

    I do use a 301 redirect if someone comes in on the old link so there are no 404's.
     
    mopacfan, Apr 27, 2007 IP