Forum Moderators: Robert Charlton & goodroi
However I have also noticed that it has indexed the homepage (/index.asp) as well as the domain name, so I'm bound to be hit by a duplicate content penalty. After 16 months it makes sense that there isn't just the sandbox at play here. So how can I create a redirect that captures non www versions of pages as well as if it contains "/index.asp" in the path?
I have been playing about with the following code:
if left(hostname,instr(hostname,".")) <> "www." then
response.status = "301 Moved Permanently"
response.addheader "Location", "http://www." & hostname & pathinfo
response.end
elseif left(pathinfo,10) = "/index.asp" then
pathinfo = ""
response.status = "301 Moved Permanently"
response.addheader "Location", "http://" & hostname & pathinfo
response.end
end if
but it just creates and endless loop and I don't know why. Please help, it's driving me crazy!
Here's a script I use on all of my asp pages. My home page is default.asp but you could change it to index.asp. Works for me. I had my host change the IIS settings so it also works on html pages as well.
<%
Dim Page
if Request.ServerVariables("SCRIPT_NAME")= "/default.asp" then
Page="/"
Else
page=Request.ServerVariables("SCRIPT_NAME")
end if
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.YOURSITE.com" & Page
End if
%>
To be honest I don't know what to do reagrding this. I think G has made the lives of ordinary webmasters a misery, as even issues such as this 'cannonicalization' can't seem to be tackled properly, and if you're on shared hosting and you have no access to IIS then you might as well give up . Other SE's don't have a problem or see a difference between domain.com and domain/index.asp, and indeed don't index both and then give a duplicate penalty, but then again they are not as..."complex"...as Google.
[google.com...]
I still don't know how to redirect my www.mydomain.com/index.asp pages to just www.mydomain.com/
It just creates an endless loop and i have no access to the IIS.
So i was just wondering whether anyone had some clever fix....
I am in a similar situation to asusplay with IIS etc.
Many shared IIS hosts support php, so the php option given on <that site> might work.
The code for a general redirect that they give is:
<?php
if (substr($_SERVER['HTTP_HOST'],0,3)!= 'www') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: ['.$_SERVER['HTTP_HOST']...]
.$_SERVER['REQUEST_URI']);
}
?>
However, they don't say what file name it should be placed in. I don't want to hijack the thread, but if this solution were to work for me, it might work for asusplay and other people on shared IIS.
Can anyone say what the file should be called?
<See Forum Charter [webmasterworld.com]>
[edited by: tedster at 11:16 pm (utc) on May 22, 2006]