Forum Moderators: phranque
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.mysite.com"
%>
<html>
It works but it can redirect page by page, since I need to redirect the whole site, I checked with my hosting server and they suggested to use 404 error pages to redirect the whole site. Besides this way, have any other ways to redirect the whole site on a windows server? Will this way be penalized by Google?
From the Microsoft website:
To redirect requests to another directory or Web site1.
In IIS Manager, expand the local computer, right-click the Web site, virtual directory, or directory within a Web site to which you want to add a redirect, and click Properties.
2.
Click the Home Directory, Virtual Directory, or Directory tab.
3.
Under The content for this resource should come from, click A redirection to a URL.
4.
In the Redirect to box, type the path to the destination directory or the URL of the Web site. For example, to redirect all requests for files in the /Catalog directory to the /NewCatalog directory on another Web site, type http://example.com/NewCatalog. The redirect must be to a fully qualified URL.
5.
Set the required flags as specified below, and then click OK. More than one flag is allowed.
[edited by: Esoos at 9:51 pm (utc) on July 21, 2006]
Also, Esoos, do you know what to do if you DO NOT have administrative access? Our serive is from Network Solutions, on a shared server, where we share with other customers.
Also, joseph_lee, 404 is definitely NOT the way to go, as 404 means error, 301 means permenant redirect. You never want to tell Google that a perfectly good page is a 404. The 301 tells Google to replace the link it sees with the link you want it to see.
The 404 might cause Google to drop your page. That's a scary thought.
[edited by: JeffOstroff at 1:52 am (utc) on July 22, 2006]
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com/new-page.asp");
}
</script>
Matt Cutts recently mention on his blog that ASP.NET 2 has some redirect bugs, so be careful there.
JeffOstroff, my understanding is that you need admin access in IIS to redirect an entire domain. Otherwise, you need to do it page by page using the code for ASP and ASP.NET outlined above.