Forum Moderators: phranque

Message Too Old, No Replies

301 redirect and 404 error page

301 redirect

         

joseph_lee

12:22 pm on Jul 19, 2006 (gmt 0)

10+ Year Member



My hosting server is a windows server, therefore, I inserted the following code to do a 301 redirect:

<%@ 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?

jatar_k

5:17 pm on Jul 21, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well, I can definitely tell you that using 404's is a stupid suggestion from your host.

a 301 for the whole site is the way to go.

What server software are you using? Apache or IIS?

Esoos

9:50 pm on Jul 21, 2006 (gmt 0)

10+ Year Member



On IIS, you'll need admin access to move your whole site.

From the Microsoft website:


To redirect requests to another directory or Web site

1.

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]

JeffOstroff

1:49 am on Jul 22, 2006 (gmt 0)

10+ Year Member



joseph_lee, where did you add that code, was it to a particular subsection of an html page? If so, where do you? Also, are you supposed to have some program running on the server to enable these commands? Does not look like standard html, and I want to try the same thing on one of our Windows based sites.

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]

Esoos

2:15 am on Jul 22, 2006 (gmt 0)

10+ Year Member



The code joseph_lee mentioned is for when your server is running ASP. If your server is running ASP.NET, then use the following to redirect an individual page:


<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.