http://domain.com to http://www.domain.com ?

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/67467?pagenum=1
05 November 2025, 07:04

Topic


weeweeslap
http://domain.com to http://www.domain.com ?
15 July 2008, 12:34


I run a dedicated server and for one of my domains I wish to redirect anyone that goes to http://DomainName.com to http://www.DomainName.com
How can I accomplish this? I appreciate your help. Thank you. -Oscar<

 

Replies ...


HuwR
15 July 2008, 12:45


just add both domains to your hostheaders, no need to do redirection for that<
weeweeslap
15 July 2008, 12:55


I have both in the host header. I just don't want them going to the non www part. Like say if you go to http://yahoo.com it automatically switches you to http://www.yahoo.com
That's what I want to do smile<
leatherlips
15 July 2008, 13:03


You could add this in the <body> of your page. I don't know if it's the best way but it will work.
Code:
<script Language="JavaScript">
location.href= ('http://www.DomainName.com');
</script>
<
HuwR
15 July 2008, 13:46


ok, est way is to set up a website for http://domain.com on its own and then redirect it to the other website (should be an option in IIS) this will then appear to the search engines as a legitimate 301 redirect, leatherlips suggestion would appear as a 302 redirect which can cause problems for SEO.
personally I would leave it as it is, why do yo need to redirect ? makes no odds to me or search engines whether to use one or the other<
bobby131313
15 July 2008, 14:04


makes no odds to me or search engines whether to use one or the other

But if both get used and indexed it can hurt you bad. It will dilute your search engine weight. Google allows you to set it now in Webmaster tools so that they will automagically convert all your weight to your choice, but the others don't, your on your own.
I have been fighting this with my forum for years and can't fix it.
Go to....
http://www.coincommunity.com/forum/ >> PR3 http://www.coincommunity.com/forum/default.asp >> PR2
Same freakin' page indexed under 2 different names, splitting PR and more importantly backlinks..... and hurting me. I went through my forum code and changes hundreds of redirects from "default.asp", still can't get them consolidated. The problem seems to be solved here, I've asked a few times how, but no one has answered that I know of. sad
The OP's scenario can hurt the exact same way.<
HuwR
15 July 2008, 14:53


But if both get used and indexed it can hurt you bad
No it won't all search engines treat www.domain.com/page.ext the same as domain.com/page.ext so long as they contain the same content, it makes no difference. www.domain.com/forum/ is not a page which is why you get problems with search indexing, it is a totally different issue<
HuwR
15 July 2008, 14:55


sorry should have explained better, when your request for http://www.coincommunity.com/forum/ comes in, the webserver has to decide what to do, so it looks for the first available default page and redirects the browser to that it does so using a 302, that is a different issue to the one being discussed.<
HuwR
15 July 2008, 15:02


bobby131313, you could try this for a solution, don't know if it will work, but it might.
1) remove default.asp from the list of default files for the website, and make sure you have no other index.hem files etc, so if you tried to open /forum/ you will get an error, probably directory listing denied or something. 2) now create a custom error page to handle that error, and use that file to rewrite the headers and do a 301 redirect to default.asp

might be worth a try if you have control over IIS<
weeweeslap
15 July 2008, 20:45


Yeah that's what I wanted to prevent, SE's indexing both www and non www of the same site. Prevent penalties of duplicate content. I also use domain.com/folder/ etc for my listings on the website I wanted to do. I'll try and do what you said Huwr, I am not sure but I'll dig in there. Thanks!<
bobby131313
15 July 2008, 21:27


No it won't all search engines treat www.domain.com/page.ext the same as domain.com/page.ext so long as they contain the same content, it makes no difference.

Sorry HuwR, but that's simply incorrect. That's exactly why Google lets you set it on the backend now. Because Gbot will index them as separate pages, I've seen them separate on sites with different PRs.
Thanks for the forum tip, I'll try it tomorrow and see what happens.<
Carefree
15 July 2008, 23:32


Originally posted by weeweeslap
I run a dedicated server and for one of my domains I wish to redirect anyone that goes to http://DomainName.com to http://www.DomainName.com
How can I accomplish this? I appreciate your help. Thank you. -Oscar

Here, try this. Save it as index.asp, change the start page to it. No matter what they type coming in, they'll go where you want them. The second bit (with the QueryString) will prevent anyone jumping straight to a page that doesn't include the www. (i.e.; http:// coincommunity.com/ cal.asp). With this in place, the URL will get modified and they'll end up at www.(url) anyway.
Code:

<%
select case Request.ServerVariables("server_name")
case "coincommunity.com"
If Request.ServerVariables("SERVER_PORT")=80 then
strDesiredURL = "http://www."
strDesiredURL = strDesiredURL & Request.ServerVariables("SERVER_NAME")
strDesiredURL = strDesiredURL & Request.ServerVariables("URL")
if request.Querystring <> "" then
strDesiredURL = strDesiredURL & "?" & request.Querystring
end if
response.redirect("http://www.coincommunity.com/index.asp")
End If
case else
response.redirect("http://www.coincommunity.com/index.asp")
end select
%>
<
SiSL
16 July 2008, 01:28


Response.Redirect command is 301 redirect so...
if request.servervariables("server_name") = "domain.com" then response.redirect("http://www.domain.com/" & request.serverVariables("script_name"))

Having 2 domains with same content gets google angry.<
HuwR
16 July 2008, 01:56


Originally posted by bobby131313
No it won't all search engines treat www.domain.com/page.ext the same as domain.com/page.ext so long as they contain the same content, it makes no difference./quote]
Sorry HuwR, but that's simply incorrect. That's exactly why Google lets you set it on the backend now. Because Gbot will index them as separate pages, I've seen them separate on sites with different PRs.
Thanks for the forum tip, I'll try it tomorrow and see what happens.
well, if you read googles own documents on SE) it states quite clearly that they are treated and indexed as the SAME content<
HuwR
16 July 2008, 01:58


Having 2 domains with same content gets google angry.
it may well do, but domain.com and www.domain.com are NOT DIFFERENT DOMAINS<
SiSL
16 July 2008, 02:00


It does gets Google angry still HuwR, lived that --it still gets it as different hosts (x.domain.com, y.domain.com are all treated as different domains), especially notified in Google Tools to select one domain for main. One of friend got a warning and Google deleted his entire indexing to have "duplicate" content. <
HuwR
16 July 2008, 03:05


Originally posted by SiSL
Response.Redirect command is 301 redirect so...
if request.servervariables("server_name") = "domain.com" then response.redirect("http://www.domain.com/" & request.serverVariables("script_name"))

Having 2 domains with same content gets google angry.
In ASP a response.redirect generates a 302 not a 301<
HuwR
16 July 2008, 03:11


Originally posted by SiSL
It does gets Google angry still HuwR, lived that --it still gets it as different hosts (x.domain.com, y.domain.com are all treated as different domains), especially notified in Google Tools to select one domain for main. One of friend got a warning and Google deleted his entire indexing to have "duplicate" content.

Canonicalization is the process of picking the best url when there are several choices, and it usually refers to home pages -- www.example.com vs. example.com vs. www.example.com/index.html. Since all these urls are different, a web server could return completely different content for all the urls above. When Google “canonicalizes” a url, it tries to pick the best one and elimintes the others.
That is from Googles own guidlines

to help it choose the correct link you can add a 301 redirect, but it is not necesary and google does NOT penalise you for it.


I will say one thing however, and I have been having this argument with my hosting clients ever since I started. You really should not be pointing domain.com at your web site anyway, that is what the www part is for. if you have to point the domain root somewhere, point it at your mail servers ip instead. <
HuwR
16 July 2008, 03:14


so your quickest solution to these issues is to remove domain.com from your host headers and the problem will never occur smile<
Shaggy
14 August 2008, 08:53


Just to add to the options already posted, here's what I have at the top of every page:

Code:
strRServer=request.servervariables("server_name")
if strRServer<>"www.domain.tld" and strRServer<>"localhost" then
strRQuery=request.querystring
if len(strRQuery)>0 then strRQuery="?"&strRQuery
response.redirect "http://www.domain.tld"&replace(request.servervariables("script_name"),"default.asp","")&strRQuery
response.end
end if
<
bobby131313
14 August 2008, 11:17


Go to....
http://www.coincommunity.com/forum/ >> PR3
http://www.coincommunity.com/forum/default.asp >> PR2

Same freakin' page indexed under 2 different names, splitting PR and more importantly backlinks..... and hurting me. I went through my forum code and changes hundreds of redirects from "default.asp", still can't get them consolidated.

Took a few months but the work finally kicked in. Now it's....
http://www.coincommunity.com/forum/ >> PR4
http://www.coincommunity.com/forum/default.asp >> Greybar

Which is exactly what I'd hoped it would do. Unless there's something I'm missing, the software really should point the redirects to the directory root, not default.asp. <
HuwR
14 August 2008, 11:27


the software really should point the redirects to the directory root, not default.asp.
what software ? if you mean Snitz then it shouldn't be redirecting you anywhere<
bobby131313
14 August 2008, 11:57


Redirects and internal links in the Snitz software is what I'm talking about.
There are 207 instances of....
<a href=""default.asp"">

Which in my opinion (and I changed) should be....
<a href=""" & StrForumUrl & """>

There are also 39 instances of...
Response.Redirect("default.asp")

and 7 instances of....
strReferer = "default.asp"

There were more that I changed, but a few months later my problems are solved.<
bobby131313
14 August 2008, 12:00


It's really not just for Google though. It's really basic stuff, IMO (and many other experts) you should always link to the folder root to be consistent and facilitate future changes.<
HuwR
14 August 2008, 12:30


not sure how you have 207 instances of <a href=""default.asp""> since there are only 78 in the base code and not once is there a link to just StrForumUrl all the forum links allways point to the forums default.asp so it is consistent.
<
HuwR
14 August 2008, 12:33


technically www.domain.com and www.domain.com/default.asp are not the same, so the forum is correct to link directly to its start file of default.asp since you may want www.domain.com to not point at default.asp but point at index.htm or even index.asp<
bobby131313
14 August 2008, 12:40


I'm not going to argue with you.
If you want to go read some, you'll find that internal linking directly to the default file name is generally considered poor coding by most webmasters. Especially since 99% of the time when people link to you externally they do not use it (and you can't control it), they link to the directory only. This inconsistency results in EXACTLY what I've fixed by changing the code. Double indexing and serious SEO dilution.
The amount of links is irrelevant. Where the links point is definitely relevant.
I've fixed mine and it worked beautifully, that's all I care about.<
HuwR
14 August 2008, 12:48


Just remember that not everyone has the forums default.asp file as the home page of their website so pointing ALL the forum links at its default.asp is not bad coding at all, it ensures that ALL the forum links point at the forum, and the forum is totally consistant in this respect.
if you need to change it because your forum default.asp is the same as your homepage then that is entirely your choice to make those changes.<
bobby131313
14 August 2008, 12:53


Just remember that not everyone has the forums default.asp file as the home page of their website

I never said that. But I would bet there are a very extreme few that it's not the home page of the forum directory.<
HuwR
14 August 2008, 13:02


it won't necesarily fix your issue any, since Icould link to the default.asp page of your forum from here and that would have the same negative effect. you need to have proper redirection scripts to fix it correctly. just changing the links in the forum won't fix it, and don't forget you have quite a few links to default.asp?CAT_ID=XX which will also bugger up your 'fix'<
HuwR
14 August 2008, 13:05


your best bet would be to leave the forum links as they were and change the default file for the forum directory under IIS to index.asp, then write an index.asp file which does a 301 redirect to default.asp then all links to the forum whether they were to / or default.asp would end up at the same url default.asp<
bobby131313
14 August 2008, 13:20


and don't forget you have quite a few links to default.asp?CAT_ID=XX which will also bugger up your 'fix'

That doesn't bugger up anything, they're different pages, why would I want to consolidate those?<
HuwR
14 August 2008, 13:45


I just told you that it did.... perfectly.
If I place a link to yourforum/default.asp here and on every other forum I have access to, that will affect your fix, which is why it is better to have proper redirection since you have no control over external links only internal links. <
bobby131313
14 August 2008, 14:08


If I place a link to yourforum/default.asp here and on every other forum I have access to, that will affect your fix

I guarantee it won't, the problem was the internal linking structure and it's quite obvious. This problem has persisted for years, I change the internal links and a couple months later it's perfect.
Besides, you're talking about deliberate behavior that is 99% against what naturally happens on the internet. Fact is, people almost never link the way you are proposing to.
You do it your way, I'll do it mine. I'm done here.<
HuwR
14 August 2008, 17:22


I'm done here.
fine, and maybe next time you can discuss the subject of the topic in question too.<
© 2000-2021 Snitz™ Communications