Results 1 to 11 of 11

Thread: [RESOLVED] 301 Redirect

  1. #1

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Resolved [RESOLVED] 301 Redirect

    Hey I have a website which is hosted externally the primary domain is www.speak-weather.com however I have since bought a new domain name www.cyprusstairlifts.com which points at the same directory and default page.

    I now have two problems firstly I want all traffic to come to my new domain and not the old one both users and search engines.

    Secondly i have noticed in my google stats it records visits to my site as
    cyprusstairlifts.com rather than the full name, again for reporting purposes it would be best if these also were reported as the full name.

    I am thinking the code below added to each page on my site is the answer but wanted to check if there are any pitfalls.

    If it wasnt my site wasnt hosted under the original name then I would disgard the speak-weather domain altogether.

    Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        'Put user code to initialize the page here 
    
        Response.Status = "301 Moved Permanently"
    
        Response.AddHeader("Location", "http://www.cyprusstairlifts.com/")
    
    End Sub
    Last edited by FishGuy; Oct 19th, 2010 at 10:20 AM.

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: 301 Redirect

    That will work ok.

    If you want to pay for another site hosting you could host your old domain in it as a perminant redirect, it would save you from coding on pages and the old domain will die soon enough anyway.
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  3. #3

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: 301 Redirect

    I tried it but it doesnt work, presumambly because If someone lands on my Default page and I try re-direct them to back to the same page it creates an infinate loop.

  4. #4
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: 301 Redirect

    Are you testing for the domain in the url before doing the redirect because you only want to redirect if they are comming from the old domain.

    Code:
    if Request.Url.Host = "speak-weather" then
        'redirect to new domain
    end if
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  5. #5

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: 301 Redirect

    ah thankyou Brin that would make more sense.

    so I need to test something like

    Code:
    if domain = "olddomainname" or domain ="domainwithoutwww" then
    
    ridirect()
    end if
    I will google how to get the domain, presumably I can obtain this from the server code without having to do any tricky javascript.

  6. #6

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: 301 Redirect

    Seems to be numerous ways, although unsure of the benefits of each im sure one will work.
    Code:
    Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL")
    Code:
    Dim CurrentURL As String = Request.Url.AbsoluteUri
    Code:
    string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
    Will try out when I get home from work this evening.

  7. #7
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: 301 Redirect

    Code:
    Request.Url.Host
    just gives you the domain on it's own, no w's before or extention after
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  8. #8

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: 301 Redirect

    That will work great for all my speakweather problems.

    but think I will need to use one of the other methods for the other issue. Google has my site listed as http://cyprusstairlifts as well as http://www.cyprusstairlifts.

    I think this messes up my google analytics as apparently it treats them seperate. Unfortunately im no expert on hosting or SEO so I have no idea why this is, but I think if I ensure everyone comes to www. via the redirect then it will show up.

    I get even more confused over this because I use a ASP.Net Master page and have the javascript in the master header, so im now not sure what it is actually reporting.

  9. #9

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: [RESOLVED] 301 Redirect

    Thanks, that worked although strangely Request.Url.Host did bring back the www. part of my URL. I just added it into my if logic so wasnt a problem.

  10. #10
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: [RESOLVED] 301 Redirect

    If your doing 301's on every domain that is not www.theDomain.com to it the search engine indexing of domain with no w's should stop. I think, maybe, I hate SEO too
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] 301 Redirect

    You might want to take a look at the following tool:

    http://www.microsoft.com/web/spotlight/seo.aspx

    Very useful!!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width