PLEASE HELP WITH 301 REDIRECT!

Discussion in 'ASP.NET / ASP.NET Core' started by kevpru, Jun 26, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I would like anytime my website is entered without the 'www' (e.g. [website].com) to automatically be redirected to 'http://www.[website].com'. I've been reading alot about this and I cannot seem to put in the correct code. I have opened my default.asp file in WordPad and added the following to the top of the code:

    <%@ Language=VBScript %>
    <%
    ' Permanent redirection
    Response.Status = '301 Moved Permanently'
    Response.AddHeader 'Location', 'http://www.[website].com/'
    Response.End
    %>

    Do I have to edit the file differently instead of simply in WordPad? I have tried using an .htaccess file, which also does not work. I don't think I can use IIS or edit the DNS. Please help, this is frustrating.
     
  2. Thanks for the reply. The code does not seem to be working. What does the ('/pages') refer to? What page do I put in there?
     
  3. Oops ,sorry that was just a comment.What seems to to be happening?Put that code in the page load event handler.It worked for me.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  4. Where's the page load event handler? What program should I use to insert the code? Right now it just comes up as text on the website.
     
  5. Following should be the content of your site's default aspx page (located in the root of your site).

     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page