|
-
Oct 15th, 2010, 09:45 AM
#1
Thread Starter
Frenzied Member
[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.
-
Oct 15th, 2010, 08:42 PM
#2
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. 
-
Oct 18th, 2010, 03:20 AM
#3
Thread Starter
Frenzied Member
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.
-
Oct 18th, 2010, 07:23 PM
#4
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. 
-
Oct 19th, 2010, 03:08 AM
#5
Thread Starter
Frenzied Member
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.
-
Oct 19th, 2010, 03:14 AM
#6
Thread Starter
Frenzied Member
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.
-
Oct 19th, 2010, 05:37 AM
#7
Re: 301 Redirect
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. 
-
Oct 19th, 2010, 06:38 AM
#8
Thread Starter
Frenzied Member
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.
-
Oct 20th, 2010, 03:23 AM
#9
Thread Starter
Frenzied Member
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.
-
Oct 20th, 2010, 04:13 AM
#10
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. 
-
Oct 27th, 2010, 11:13 AM
#11
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|