Posts Tagged ‘301 Redirects’

SEO School: 301 Redirects & Canonical Redirects for Microsoft IIS Web Servers

To Perform this you need administrative access to the IIS Server Application. If you do not have this then you can do the redirects in ASP or PHP.

Single Page Redirect:

  1. Open Internet Services Manager then “right-click” on the file or folder you want to redirect to a new page or folder.
  2. Select “redirection to a URL”.
  3. Enter the URL where you want the redirect to go to.
  4. Check the fields: “exact url entered above” and “A permanent redirection for this resource”.
  5. Click “Apply”.

PHP 301 Redirect
This is added to the page that you want to redirect to a new page, it is triggered on the request for the specific page and the file will actually return the redirect.

Single Page Redirect:

<?php
header(’HTTP/1.1 301 Moved Permanently’);
header(’Location: http://www.new-url.com/’);
?>

PHP Canonical Redirect:
(non-www to www)

<?php
if (substr($_SERVER['HTTP_HOST'],0,3) != ‘www’) {
header(’HTTP/1.1 301 Moved Permanently’);
header(’Location: http://www.’.$_SERVER['HTTP_HOST']
.$_SERVER['REQUEST_URI']);
}
?>

Redirects & Canonical Redirects for Active Server Pages (ASP)

Single Page Redirect:
This is placed on the page you are redirecting and is triggered when someone tries to access the page.

<%@ Language=VBScript %>
<%
Response.Status=”301 moved permanently”
Response.AddHeader “Location”, “http://www.domain.com/”
%>

ASP Canonical Redirect:
(non-www to www):
This code should be inserted into a global include file or any script which is executed for every page on the site before the page output begins. If your programmers are using ASP.net and/or they are not using a global file, you need to have them address this issue or perform the Canonical Redirect from the IIS Server Application (as above).

<%
If InStr(Request.ServerVariables(”SERVER_NAME”),”www”) = 0 Then
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.”
& Request.ServerVariables(”HTTP_HOST”)
& Request.ServerVariables(”SCRIPT_NAME”)
End if
%>

301 Redirects for ASP.NET

For Single Pages:

<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(”Location”,”http://www.domainname.com/new-page.aspx”);
}<…

Canonical Redirect for ASP.NET (ASPX):

For ASP.NET you need to do this individually in the Windows IIS Internet Services Manager or Use The ASP Code above in a global file that wil process the redirect BEFORE any other processes.

301 Redirects for Macromedia ColdFusion

Since cold fusion is usually hosted on Windows, Linux, and Sun. The .htaccess and Windows IIS tutorials above will have solutions for the Canonical and redirects. This is for a Single Page Redirect embedded directly into the file:

<cfheader statuscode=”301″ statustext=”Moved permanently”>
<cfheader name=”Location” value=”http://www.new-location.com/”>

301 Redirects for Sun Web Servers

In order to do this on a SUN platform you have to rewrite the SUN Web Server’s standard action of always using a 302 redirect to always use a 301 redirect. You have to open the obj.conf configuration file and add the following lines below the <Object name=”default”> line:

<Client code=”302″>
Output fn=”set-variable” error=”301″ noaction=”true”
</Client>

The above will make the SUN web server to return 301 permanent redirect responses for all redirects. If you only want to use a 301 permanent redirect response for certain URLs or files, you can add following to the bottom of obj.conf:

<Object ppath=”path”>
<Client code=”302″>
Output fn=”set-variable” error=”301″ noaction=”true”
</Client>
</Object>

SEO Webmaster Tags: , , , , , , , , , , , , , , , ,

SEO Webmaster Related posts

GOOGLE TOP 10
Google ads