locked
Redirect from default.aspx to website root RRS feed

  • Question

  • User1405114533 posted

    I have the problem of a client who wants to do a 301 redirect for all traffic that lands on the page.

    http://www.domain.com/default.aspx to

    http://www.domain.com/

    Now I've searched and searched and tested a number of code snippets which use httphandlers, but nothing seems to work. Has anyone successfully done this before?

    I've heard that it cant be done from asp.net, and needs to be done in iis, but i cant even find any examples of how to do this.

    Any help would really be really appreciated

    Friday, September 7, 2007 12:19 AM

All replies

  • User1622957740 posted

    What's wrong with

    Response.Redirect("http://www.domain.com/")
    Repsonse.End()

    in a handler or module?

     

    Saturday, September 8, 2007 5:07 PM
  • User-501578066 posted

    Response.Redirect is a 302 temporary redirect if I remember it correctly.
    Use
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location",http://www.domain.com);

    Best regards
    Claus

    Sunday, September 9, 2007 2:12 PM
  • User1405114533 posted

    Yes but how do i tell if i need to redirect or not? If i do that on the root page, its just going to start looping. I need a way of telling if they typed in the whole domain with the /default.aspx or just the domain.

     

    Sunday, September 9, 2007 5:45 PM
  • User1622957740 posted

    Not sure what you're asking. You can look at the Request.Url to determine the original Url and the URL that the redirect is supposed to go to and based on that decide on what needs to be done.

    +++ Rick ---

     

    Sunday, September 9, 2007 7:17 PM