Submit Your Article Forum Rules

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: ASP dynamic 301 redirect based on Product ID

  1. #1
    WebProWorld MVP rumblepup's Avatar
    Join Date
    Jul 2003
    Posts
    308

    ASP dynamic 301 redirect based on Product ID

    I've been going nuts about this for awhile, but I just can't find the answer. I'm not a coder, but a script scraper, so I'm dead if I can't do this.

    I'm changing a site over from asp to asp.net. One of the problems I'm having is 301 redirecting all of the dynamic urls to their new counterparts. There was only one constant I was able to maintain in the dabase migration, and it was the product table UID (ID's) Those are all the same and the basis for product navigation in both applications.

    Well here is my problem. I need to do a 301 redirect from three files:

    1. default.asp: (No problem really, just giving you background)

    2. prodList.asp: Which are the Category Navigation pages. These look like this:
    prodList.asp?idCategory=26

    and finally
    3. prodView.asp: which is the product detail view.
    These look like this:
    prodView.asp?idproduct=418

    Ok.
    For default.asp, just a 301 redirect. Found it here in the forums, no problem.

    For prodList.asp, I have to 301 redirect to a corresponding Category page which looks like
    SearchResult.aspx?CategoryID=(ID)

    I have to do these by hand because the Category ID's are not consistent. I had to re-categorize for better SEO.
    So how do I construct an IF/Then statement for the following logic
    IF
    prodlist.asp?idCategory=(ID)
    then redirect to
    SearchResult.aspx?CategoryID=(ID)
    IF Not
    Then
    IF
    And so on.

    And then there is the prodView.asp page. I have to redirect these to like this
    prodView.asp?idproduct=(UID)
    detail.aspx?=ID(UID)
    both the UID numbers will be the same number.

    I'm hoping that I can do this with a couple of lines of code , to make life easier for myself.

    Any help. Please! Please! Please! Please!
    (I ain't to proud to beg)

  2. #2
    WebProWorld MVP incrediblehelp's Avatar
    Join Date
    Jan 2004
    Posts
    7,567
    So you don't want to simply list all the old URLs in the htaccess file with the corresponding new URLs?

    Your trying to do this with a wildcard somehow?

  3. #3
    WebProWorld MVP rumblepup's Avatar
    Join Date
    Jul 2003
    Posts
    308
    So you don't want to simply list all the old URLs in the htaccess file with the corresponding new URLs?
    IIS hosting. Doesn't have cool htaccess


    Your trying to do this with a wildcard somehow?
    Nope. With the prodlist.asp page I'll be manually coding 301 redirect from old Category ID to new Category ID....problem is, I don't know how.

    With prodview.asp, kinda sorta.
    The one constant, as I said, is the product UID. So even though the page name is different, the ID's are the same.

    So the argument is
    IF
    prodView.asp?idproduct=(querystringID)
    then
    detail.aspx?=ID(querystringID)

  4. #4
    WebProWorld MVP rumblepup's Avatar
    Join Date
    Jul 2003
    Posts
    308
    Ok, how about this. Instead of pointing a product display page to the corresponding product display page in the new ap, what if I point all of the old product pages to a special page I have called all products, which is a list of all active products.

  5. #5
    Junior Member
    Join Date
    Sep 2005
    Posts
    4

    isapi rewrite

    If your urls have some sort of pattern to the conversion you can use a tool called isapi rewrite. I use it to make my urls for our shopping cart users more search engine friendly but you could also use it to do the redirect like this. Conversely just make a delimited text file and read it in from your not found page and if it finds a matching url it goes to the new page perhaps??

  6. #6
    WebProWorld MVP rumblepup's Avatar
    Join Date
    Jul 2003
    Posts
    308
    ISAPI rewrite not available.

  7. #7
    Senior Member ADAM Web Design's Avatar
    Join Date
    Dec 2003
    Posts
    2,172
    If you can get a custom 404 installed, you can do it that way.

    What you do is you set up the 404 to gather the URL, including the querystring. Then you'd extract the querystring and redirect to the new URL.

    I don't have a code sample whipped up to show you the gathering of an old URL to a new URL (since that's situation-specific), but I do have some generic ASP 301 code here:

    http://www.walkonmypath.com/asp-301-redirect-code/

    (It's the proper 301 code too...battle-tested to the hilt.)

  8. #8
    use it for 301 redirection from .asp page to .aspx page > write it in old .asp page

    <%@ Language=VBScript %>
    <%
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", "http://www.yourdomain.com/yourpage.aspx"
    %>

    I think you can made it.

  9. #9
    Junior Member
    Join Date
    Nov 2005
    Posts
    9
    Use this code for default.asp
    Code:
    <%@ Language=VBScript %>
    <%
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", "http://www.yourdomain.com/default.aspx"
    Response.End
    %>
    Use this code for prodlist.asp
    Code:
    <%@ Language=VBScript %>
    <%
    Dim CategoryID
    CategoryID = Request.QueryString("idCategory")
    
    'Here you can insert some processing for category ID if you need
    If IsNumber(CategoryID) Then
    	CategoryID = CLng(CategoryID)
    Else
    	'Some default category
    	CategoryID = 111
    End If
    
    If CategoryID = 1 Then
    	CategoryID = 10
    ElseIf CategoryID = 2 Then
    	CategoryID = 22
    End If
    'Here you can insert some processing for category ID if you need
    
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", "http://www.yourdomain.com/SearchResult.aspx?CategoryID=" & CStr(CategoryID)
    Response.End
    %>
    Use this code for prodView.asp
    Code:
    <%@ Language=VBScript %>
    <%
    Dim ProductID
    ProductID = Request.QueryString("idproduct")
    'Check the ID
    If Not IsNumber(ProductID) Then
    	ProductID = "111" 'Some default product
    End If
    'Check the ID
    
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", "http://www.yourdomain.com/detail.aspx? ID=" & ProductID
    Response.End
    %>
    I suppose it should work.

  10. #10
    WebProWorld MVP rumblepup's Avatar
    Join Date
    Jul 2003
    Posts
    308
    You my friend....ARE AN ANIMAL!!!

    The script works GREAT!

    One problem I found,

    <%@ Language=VBScript %>
    <%
    Dim ProductID
    ProductID = Request.QueryString("idproduct")
    'Check the ID
    If Not IsNumber(ProductID) Then
    SHOULD BE
    If Not IsNumeric(ProductID) Then
    ProductID = "111" 'Some default product
    End If
    'Check the ID

    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", "http://www.yourdomain.com/detail.aspx? ID=" & ProductID
    Response.End
    %>


    Other than that.

    OMG, now I can relax, throw back a Cuba Libre and a Glazed donut.

    Thank you! Thank you! Thank you! Thank you! Thank you!

Page 1 of 2 12 LastLast

Similar Threads

  1. Dynamic Image processing catalog Product
    By jai.subramanian in forum eCommerce Discussion Forum
    Replies: 0
    Last Post: 09-17-2009, 11:36 PM
  2. Replies: 28
    Last Post: 10-29-2008, 09:59 AM
  3. 301 Redirect on dynamic site
    By netfrugal in forum Search Engine Optimization Forum
    Replies: 1
    Last Post: 10-03-2006, 08:05 PM
  4. 301 redirect for dynamic site
    By b2bseo in forum Google Discussion Forum
    Replies: 0
    Last Post: 09-09-2005, 02:45 AM
  5. mailform redirect based upon user selection
    By twopooches in forum Web Programming Discussion Forum
    Replies: 5
    Last Post: 06-25-2004, 03:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •