Redirect scripts
author: mike foskett incept: 19th May 2009
last update: 2nd February 2010
A collection of permanent redirect scripts in various languages.
(X)HTML version
Uses a meta refresh URL redirect:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Redirecting</title>
<meta http-equiv="refresh" content="0;url=http://websemantics.co.uk/">
</head>
<body>
</body>
</html>
The problem with this is that it isn't search engine friendly and the back button is broken.
Personally I'd add actual content to this page. Well at least a h1 heading and a paragraph explaining the page has moved and a link where to.
<h1>Page has moved</h1>
<p>
It now resides here:
<a href="http://websemantics.co.uk/">
Page title
</a>
</p>
Javascript version
In Javascript the best method is to use the location replace as it doesn't break the back button:
location.replace('http://websemantics.co.uk/');
Again the problem is that it isn't search engine friendly.
PHP version
The use of a 301 response in the header
<?php
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://websemantics.co.uk/" );
?>
ASP version
<%@ Language=VBScript %>
<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://websemantics.co.uk/"
%>
ASPX (.net) version
<%@ Page Language = "C#" %>
<script runat = "server">
private void Page_Load ( object sender, System.EventArgs e ) {
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://websemantics.co.uk/");
}
</script>
If you have any alternate redirects, especially in other laguages, why not email me or post them below for inclusion?
Have your say…
2
mike foskett replies:
16 12 2009
Sorry Dan.
It should of read Permanant Redirects. I've amended the content.
As to the temporary redirect? Usable but not recommended for permanant redirection.
The commenting system used here is a modified version of comment_rave.

1
Dan
02 12 2009
Can I use
header("HTTP/1.1 307 Temporary Redirect");
or not?