Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb/web234/b2344/sl.harringtonweb/public_html/pmwiki2.php:2) in /hermes/bosweb/web234/b2344/sl.harringtonweb/public_html/pub/skins/simple/simple.php on line 39

Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb/web234/b2344/sl.harringtonweb/public_html/pmwiki2.php:2) in /hermes/bosweb/web234/b2344/sl.harringtonweb/public_html/pmwiki2.php on line 866
Harrington Web : Brian - Redirect Page

Home > Projects > Redirect Page


I occasionally need to create a page that redirects to another page, e.g, when a site is moved. Three versions are provided here:

  • A JSP page that sends a 301 status code indicating a permanent move.
  • A PHP page that sends a 301 status code.
  • A plain HTML page using the meta refresh tag.

JSP Page

<%
response.setStatus(301);
response.setHeader("Location", "http://www.newurl.com");
%>

PHP Page

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newurl.com");
exit();
?>

Meta Refresh Tag

<html>

<head>
    <title>Page Moved</title>
    <meta http-equiv="Refresh" 
        content="0; url=http://www.newurl.com">
</head>

<body>
    <h1>Page Moved</h1>
    <p>This page has been moved to <a href="http://www.newurl.com">
        http://www.newurl.com</a>.</p>
</body>

</html>
 
Page last modified on June 24, 2006, at 03:22 PM.