Successful way to Rewriting URLs with ASP?

Discussion in 'ASP General' started by Toni, Nov 3, 2008.

  1. Toni

    Toni Guest

    Does anyone have a recommended method of rewriting URLs with classic ASP?

    For example, if the browser shows the Friendly URL
    www.mydomain.com/blue_widget

    my app will show the following Content Page
    www.mydomain.com/item.asp?id=32&type=d&color=blue

    Right now, I'm experimenting with having my error 404 file do the redirect. But it's not
    as clean as I'd like - if I do a Server.Transfer or Server.Execute to the content page
    (the query strings are passed as session variables), the PATH_INFO shows that the URL is
    my error 404 file, which messes up my SmarterStats site statistics (BTW, "Smarter"Stats
    is actually pretty dumb).

    If my error 404 file performs a Response.Redirect, the address bar sometimes shows the
    Content Page URL instead of the Friendly URL, defeating the purpose.

    Before deciding to spend the time, energy, and effort to move to ASP.NET 2.0, can anyone
    tell me if you've successfully implemented a rewriting URL method that makes you happy?
    Can the ASP.NET web.config file be made to work in this to successfully rewrite URLs?

    Thanks!!!

    Toni
     
    Toni, Nov 3, 2008
    #1
    1. Advertising

  2. Toni

    daddywhite Guest

    http://www.isapirewrite.com/

    OR

    http://www.qwerksoft.com/products/iisrewrite/

    I have sucessfully used both of these on my websites to do URL
    rewrites.

    For dynamic URLs you still need the ID in the URL somewhere eg:

    /product/45/my_product_name.htm ====> /prod_page.asp?ID=45

    unless of course you want to write rules for all the individual
    dynamic pages, which kinda defeates the point of a URL rewrite and
    dynamic website!

    Cheers.
     
    daddywhite, Nov 3, 2008
    #2
    1. Advertising

  3. Toni

    Toni Guest

    Looks nice. But because I'm on a shared server, I'd like to exhaust all other solutions
    before I install a server component.


    "daddywhite" wrote...
    > http://www.isapirewrite.com/
    >
    > OR
    >
    > http://www.qwerksoft.com/products/iisrewrite/
    >
    > I have sucessfully used both of these on my websites to do URL
    > rewrites.
    >
    > For dynamic URLs you still need the ID in the URL somewhere eg:
    >
    > /product/45/my_product_name.htm ====> /prod_page.asp?ID=45
    >
    > unless of course you want to write rules for all the individual
    > dynamic pages, which kinda defeates the point of a URL rewrite and
    > dynamic website!
    >
    > Cheers.
     
    Toni, Nov 3, 2008
    #3
  4. "Toni" <> wrote in message
    news:...
    > Looks nice. But because I'm on a shared server, I'd like to exhaust all
    > other solutions
    > before I install a server component.
    >


    Then consider other solutions exhausted. The best you can do when all
    you've got to play with is native ASP is the 404 hack.

    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Nov 4, 2008
    #4
  5. Toni

    daddywhite Guest

    Possible other way, but a bit shit, would to PHYSICALLY create a
    folder called:"blue_widget". In that have an index.asp page which
    defines any variables required and then does a server.execute on the
    dynamic page:

    ############ index.asp in blue_widget folder ##########

    Session("pageID") = 67
    Server.Execute "displaypage.asp"

    ################################################

    Obviously you would have to have display page use the session pageid
    rather than a querystring.

    Essentially this is very similar to the 404 hack but not quite as
    dynamic so assume you wouldnt want to use this!! Just a thought
    though.
     
    daddywhite, Nov 4, 2008
    #5
  6. Toni

    Vicent Lauv Guest

    Hi Toni

    I have new to Asp Developer however, i came across as the same your problem.
    You would like your page. at www.mydomain.com/blue_widget. It is very simple
    way to use your 404 Customer Error Code.

    for example: if your site www.domain.com/holidays/trip-for-active-osaka.asp

    you probablely can have www.domain.com/Trip_for_Active_Osaka

    My 404.asp

    <%
    Dim strURL
    Dim strBolum
    Dim strSQL

    Set strURL = Request.ServerVariables("QUERY_STRING")
    strBolum = Split(strURL1,"/")

    If strBolum("3") = "Trip_for_Active_Osaka" Then
    Server.Execute("holidays/trip-for-active-osaka.asp")

    End If

    %>

    i alraedy implemented this method mostly on www.cambodia-tourism.org
    If you need help. You can contact me at Cambodia Tourism Site

    Teachnology Change the World.
     
    Vicent Lauv, Jan 21, 2009
    #6
  7. Toni

    Evertjan. Guest

    =?Utf-8?B?VmljZW50IExhdXY=?= wrote on 21 jan 2009 in
    microsoft.public.inetserver.asp.general:

    > Hi Toni


    [please always quote on usenet, this is not email]

    > I have new to Asp Developer however,


    Sometimes I have new too.

    > i came across as the same your problem.
    > You would like your page. at www.mydomain.com/blue_widget. It is very
    > simple way to use your 404 Customer Error Code.
    >
    > for example: if your site
    > www.domain.com/holidays/trip-for-active-osaka.asp
    >
    > you probablely can have www.domain.com/Trip_for_Active_Osaka
    >
    > My 404.asp
    >
    > <%
    > Dim strURL
    > Dim strBolum
    > Dim strSQL


    Why "Dim"?

    It does not hurt, but in a short piece of asp it is superfluous

    > Set strURL = Request.ServerVariables("QUERY_STRING")


    Why "Set"?

    This is wrong,
    as you just assigne a value to a variable.
    Set is for objects.

    > strBolum = Split(strURL1,"/")
    > If strBolum("3") = "Trip_for_Active_Osaka" Then
    > Server.Execute("holidays/trip-for-active-osaka.asp")


    Why "Server.Execute"?

    Use "server.transfer"

    because you do not want to come back to 404.asp, meseems

    > End If
    >
    > %>
    >
    > i alraedy implemented this method mostly on www.cambodia-tourism.org




    > If you need help. You can contact me at Cambodia Tourism Site


    It is good to have new experts going such length,
    but this is usenet. ;-)


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jan 21, 2009
    #7
  8. Vicent Lauv wrote:
    > Hi Toni
    >
    > I have new to Asp Developer however, i came across as the same your problem.
    > You would like your page. at www.mydomain.com/blue_widget. It is very simple
    > way to use your 404 Customer Error Code.
    >
    > for example: if your site www.domain.com/holidays/trip-for-active-osaka.asp
    >
    > you probablely can have www.domain.com/Trip_for_Active_Osaka
    >
    > My 404.asp
    >
    > <%
    > Dim strURL
    > Dim strBolum
    > Dim strSQL
    >
    > Set strURL = Request.ServerVariables("QUERY_STRING")
    > strBolum = Split(strURL1,"/")
    >
    > If strBolum("3") = "Trip_for_Active_Osaka" Then
    > Server.Execute("holidays/trip-for-active-osaka.asp")
    >
    > End If
    >
    > %>
    >
    > i alraedy implemented this method mostly on www.cambodia-tourism.org
    > If you need help. You can contact me at Cambodia Tourism Site
    >
    > Teachnology Change the World.
     
    Agile Consulting, Feb 9, 2009
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    4
    Views:
    2,116
    Ralf Hildebrandt
    Sep 8, 2003
  2. Dan
    Replies:
    0
    Views:
    358
  3. Kaidi
    Replies:
    5
    Views:
    475
    Andrew Thompson
    Jan 4, 2004
  4. Smokey Grindle

    rewriting URLs?

    Smokey Grindle, Jun 21, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    366
    Alan Silver
    Jun 27, 2006
  5. IanW
    Replies:
    1
    Views:
    423
Loading...

Share This Page