Borbin the 🐱

Redirect HTML pages

05 February, 2013


Redirect web pages is common practice and often done with the meta tag refresh, but there are drawbacks and it is not recommended by the W3C. Using a HTTP redirection status code is preferred, but often simply not practical.
If you have a page http://oldsite.com/project/index.html and you need a redirect to http://mysite.com/project/, you simply place this index.html in http://oldsite.com/project/. In case JavaScript is disabled, the default meta refresh is used as a default:

index.html

<!DOCTYPE HTML>
<html>
<head>
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta http-equiv="refresh" content="1; URL=http://mysite.com/project/" />
    <script type="text/javascript">
        window.location.href = "http://mysite.com/project/"
    </script>
</head>
<body>
</body>
</html>