Forum Moderators: open
I have a client who has ASP sites and used to hold top spot for years in his industry. Recently, some scraper used a URL for his sites that had no www. and now he is getting dup content hit. I know that I need to do a 301 or 302 being that it is on a windows box, but I am not sure since most of my experience is in apache and php.
Can anyone please provide me with detailed instructions on performing the proper redirect, server-side, for asp?
Thanks All.
Benny
1) Make an empty directory on your server and place into it a single page called 404.asp
2) Change your home directory in IIS to point to that directory.
3) In IIS, change your custom error for 404s to point to that relative URL (i.e. Select Relative URL and type in /404.asp)
The content of /404.asp should be:
<%@LANGUAGE="VBScript"%>
<%
Dim varFile:varFile = Request.querystring
Dim requestpage:requestpage = replace(varFile,"404;","")
Dim splitFile:splitFile = Split(requestpage,"?")
Dim splitnewFile:splitnewFile = Split(requestpage,":")
Dim newpage
newpage = splitnewfile(2)
If instr(newpage,"/") > 0 then
newpage = mid(newpage,(instr(newpage,"/") + 1))
Else
newpage = ""
End if
response.redirect "http://www.whatever.com/" & newpage
%>
put your code in either of the following, depending on how often you really need to check the url:
this is ASP.net C#
protected void Session_Start(Object sender, EventArgs e)
{
}
protected void Application_BeginRequest(Object sender, EventArgs e)
{
}