301 Redirect - I've Tried Everything, Please Help!

Discussion in 'HTML & Website Design' started by rbf738, Sep 29, 2009.

  1. #1
    I want to redirect one subdomain to another subdomain in the same domain.

    Godaddy hosting replied to me saying: The hosting account you are currently running is a Windows shared hosting account. With the Windows based hosting, you will want to use the ASP code for the redirect, as PHP runs off of the Linux hosting accounts.

    Can anyone tell me what code to use and how it should look if I want to redirect:

    http://www.exa*mple.com/apples/index.html

    to

    http://www.exa*mple.com/oranges.html


    It looks like the code that Godaddy recommended is:

    ASP .NET - save this as oldpagename.aspx
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","http://www.new-url.com");
    }


    Please use my examples in the code as I'm daft enough to need that at this point.

    And finally, which directory on my hosting do I upload this file to once I'm done? The root for "exa*mple"? Thanks.
     
    Last edited: Sep 29, 2009
    rbf738, Sep 29, 2009 IP
  2. rbf738

    rbf738 Peon

    Messages:
    475
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I just opened a notepad file and inserted:


    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","http://www.exa*mple.com/oranges.html");
    }

    ...Saved it as "apples.aspx" and uploaded it to the root of the "exa*mple" folder, but the redirect is not happening as the apples site is still loading up. What's going wrong here?
     
    rbf738, Sep 29, 2009 IP
  3. ErikTheRed

    ErikTheRed Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So are you saying that when you go to http://www.exa*mple.com/apples/index.html you want the redirect to occur?

    If so you need to add something like

    
    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","http://www.exa*mple.com/oranges.html");
    }
    </script>
    
    Code (markup):
    to your http://www.exa*mple.com/apples/index.html page.

    That should work.
     
    ErikTheRed, Sep 29, 2009 IP
  4. renownedmedia

    renownedmedia Well-Known Member

    Messages:
    65
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    100
    #4
    Try naming it index.aspx
     
    renownedmedia, Sep 29, 2009 IP
  5. rbf738

    rbf738 Peon

    Messages:
    475
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I added that code to the bottom of my apples page and reuploaded it, it didn't work.


    I have other files named .index in different folders on my site. I tried doing that and putting it in both the root folder of the main domain as well as the subdomain for the old site and it didn't work, anyway.

    What about a meta redirect? Is that what it's called? I use that for affiliate links and all of that, so I suppose I could just delete all content from the apples page and put a meta redirect, would I keep the links and all that this way?

    Help I've tried everything here!
     
    rbf738, Sep 29, 2009 IP
  6. klarkinphotos

    klarkinphotos Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This is the code i use

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Your Title</title>
    <meta http-equiv="REFRESH" content="3;url=http://Yoursite.WTV"></HEAD>
    <BODY>
    Your Msg
    </BODY>
    </HTML>

    the #3 after content is how many seconds it waits to send you to the new link
     
    klarkinphotos, Sep 29, 2009 IP
  7. rbf738

    rbf738 Peon

    Messages:
    475
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks, I think I'm straight on doing a meta redirect, but I thought rankings don't transfer as easily that way so it's best to do a 301 which I still need help with if anybody reads this thread. Thanks.
     
    rbf738, Sep 29, 2009 IP
  8. Tedel

    Tedel Well-Known Member

    Messages:
    326
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    130
    #8
    If you have access to your .htaccess file, just include

    301 redirect /old-url-path new-full-url-including-http
     
    Tedel, Sep 30, 2009 IP
  9. renownedmedia

    renownedmedia Well-Known Member

    Messages:
    65
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    100
    #9
    I believe he's using an IIS server
     
    renownedmedia, Sep 30, 2009 IP
  10. rbf738

    rbf738 Peon

    Messages:
    475
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I am, I've tried the htaccess to no avail.
     
    rbf738, Oct 1, 2009 IP