Forum Moderators: open
I have identified 2 inbound links that don't include the "www." and I will get these changed without delay.
I can't stop this dual-personality by using a permanent redirect because they are one and the same - it's just that our server recognises both as valid domain names. Surely this is pretty standard?
SE positioning for this site absolutely sucks but used to be OK. It's as if the SEs are steering clear of duplicate content.
If I view the Google cache for site with and without www., the same content is displayed. Google regularly caches the home page but doesn't even display it for the company name, for which there is nearly no competition. I think G and the other SEs are viewing it as two different sites and that this has tripped a filter.
Is there anything definite I can do to resolve this?
Is there anything definite I can do to resolve this?
301 Moved Permanently from the non www to the www version. That is really the only way that I am aware of.
When setting up the 301, make sure to enter the target URI as such...
http://www.example.com[b]/[/b] With the trailing forward slash. So, any requests for
http://example.com will now permanently redirect (301) to http://www.example.com/. Once you've got this set up, you'll want to check your server headers to make sure the correct information is being returned. Here's an example of the server header output for a 301...
Server Response: http://example.com
HTTP Status Code: HTTP/1.1 301 Moved Permanently
Location: http://www.example.com/
Server: Server Name
Content-Type: text/html
Content-Length: 153 P.S.
http://example.com is a sub-domain of http://www.example.com/ and can be two totally different sites. Most search engines I think realize this and effectively merge the two together. But, when you have incoming links to both non www and www, I believe that is where issues could arise.
<%
dim domainname, i, s
domainname = request.servervariables("HTTP_HOST")
i = instr(1, lcase(domainname), "www")
if i=0 then
Response.Status = "301 Moved Permanently"
s = "http://www.example.org" & Request.ServerVariables("SCRIPT_NAME") & "?"
s = s & Request.ServerVariables("QUERY_STRING")
Response.addheader "Location", s
Response.End()
end if
%>
This produces the following server headers:
Server Response: [example.com...]
Status: HTTP/1.1 301 Moved Permanently
Server: Microsoft-IIS/5.0
Date: Thu, 05 Feb 2004 11:06:33 GMT
X-Powered-By: ASP.NET
Location: [example.com...]
Content-Length: 0
Content-Type: text/html
Cache-control: private
I am slightly concerned about the Location info. I did it with and without a trailing slash. With / showed it as //index.asp? and without / shows it as /index.asp? but I can't get it to just read [example.com...]
Also, Content-Length: 0
Is this a problem?
Thank you, M
[edited by: pageoneresults at 2:44 pm (utc) on Feb. 5, 2004]
[edit reason] Examplified URIs [/edit]
<html> tag... <%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.example.com/"
%> If you are using ASP.NET, this is the code that would go above the opening
<html> tag... <script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com/");
}
</script>
Server Response: http*//domain.com/
Status: HTTP/1.1 301 Moved Permanently
Server: Microsoft-IIS/5.0
Date: Thu, 05 Feb 2004 11:06:33 GMT
X-Powered-By: ASP.NET
Location: http*//www.domain.com/[b]index.asp?[/b]
Content-Length: 0
Content-Type: text/html
Cache-control: private Its okay to have the location with the /index.asp. But, you do not want the question mark there. Here is one thing to think about. If you ever change the underlying technology of the site, that URI with the /index.asp is going to get indexed. You'll have to go back and try to update any and all references to that /index.asp if something changes underneath. Tis not a task I would want to be responsible for. ;)
P.S. I checked a few of my 301s and they all return a number in the Content-Length field. Something doesn't seem right with the above.
Redirect a domain such as example.com to www.example.com [xoc.net]
Can you face having one last look at something?
We had to change the pages site-wide to get rid of the two-sites problem. It's an .asp site with some static pages and some generated on the fly. We've ended up with this as the server header output:
<%
dim domainname, i, s
domainname = request.servervariables("HTTP_HOST")
i = instr(1, lcase(domainname), "www")
if i=0 then
Response.Status = "301 Moved Permanently"
s = "http://www.domain.com" & Request.ServerVariables("SCRIPT_NAME") & "?"
s = s & Request.ServerVariables("QUERY_STRING")
Response.addheader "Location", s
Response.End()
end if
%>
The Location shows with "?" at the end but this is to cope with any possible parameters.
Content-Length is still: 0
We've been working on this all day and can't make it say anything else!
Do you know of anything else we can try? And does the rest of it look OK to you?
V. grateful - Millie
<%
dim domainname, i, s
domainname = request.servervariables("HTTP_HOST")
i = instr(1, lcase(domainname), "www")
if i=0 then
Response.Status = "301 Moved Permanently"
s = "http://www.domain.com"
if request.servervariables("script_name") <> "index.asp" then
s = s & Request.ServerVariables("SCRIPT_NAME")
end if
if len(request.servervariables("query_string") > 1 then
s= s & "?" & Request.ServerVariables("QUERY_STRING")
end if
Response.addheader "Location", s
Response.End()
end if
%>
but i would recommend handling this through mmc so you dont have to add the above code to every single page. Create a new site in your mmc and name it www.yourdomain.com, point the home directory to where all your files are located.. then go to the properties of the site yourdomain.com and instead of setting the home directory set it to redirect all requests to www.yourdomain.com. The only possible downfall to this approach is the status response will be 301 Error.. but it seems to work fine because at least the 301 part is in there.