« Previous Next »

Answered Thread: code-based 301 redirect in classic ASP

Last post 10-27-2009 9:39 PM by steve schofield. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 10-24-2009, 5:24 PM

    • mgovan
    • Not Ranked
    • Joined on 10-24-2009, 7:30 PM
    • Posts 3

    code-based 301 redirect in classic ASP

    On our 2003/IIS6 servers, the following code works fine.

    redirect_url = "/folder/page.html"
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location",redirect_url

     However, on our new 2008/IIS7 server, we get rediected to the following
    .. assuming redirect_url could be any page (rewritten to mask page.asp?query=123&.. etc), which are dyamically created (based on location, page type, etc, so there's no 1-1 relationship between start URL and redirect URL, or at least far too many to manually map

    http://www.oursite.com/folder/page.html,/folder/page.html
    (redirect_url comma redirect_url)

    sometimes it'll even just do multiple ,/folder/page.html in the URL

    This takes the user to our 404 page.

    response.redirect redirect_url
    works, however that completely defeats the purpose of the 301 redirect.

    Has anyone managed to get code-level 301 redirects working under IIS7 w/ classic ASP? I've spent the last couple days searching google, and have come up empty so far.

     Thanks

  • 10-24-2009, 10:43 PM In reply to

    Re: code-based 301 redirect in classic ASP

    Have you tried putting the application pool in classic mode?

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 10-26-2009, 2:11 PM In reply to

    • mgovan
    • Not Ranked
    • Joined on 10-24-2009, 7:30 PM
    • Posts 3

    Re: code-based 301 redirect in classic ASP

    When I first got access to the server, the app pools were a mix of classic and integrated, but I changed them all to classic, no managed code. Tried restarting IIS, rebooting the server, no change.

    One thing to mention (hopefully unrelated), we are running Isapi/Rewrite2 by Helicon (same setup as our IIS6 servers). All the rewrites work fine on their own. Issue just comes up when there's a 301 involved.

  • 10-26-2009, 3:00 PM In reply to

    • mgovan
    • Not Ranked
    • Joined on 10-24-2009, 7:30 PM
    • Posts 3

    Answered Re: code-based 301 redirect in classic ASP

    It looks like we have a code-based solution. Looks like IIS7 isn't as lenient as IIS6 was on its redirection rules.

     redirect_url = "/folder/page.html"
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location",redirect_url
    Response.end

    If we don't add the response.end, it seems IIS just keeps running the addheader over and over again.

    Going to spend a bit more time to see if we can find an IIS-based solution, rather than having to update the code (887 matches in 134 files... going to be a long day otherwise)

  • 10-27-2009, 9:39 PM In reply to

    Re: code-based 301 redirect in classic ASP

    I'm not expert in IIS URLRewrite.  I'd ask over there and describe your situation.  Maybe there is some magical fix.

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
Page 1 of 1 (5 items)
Microsoft Communities