Home > html > HTML automatic redirect

HTML automatic redirect

Problem

You have an HTML page and you want to redirect the user to a new page in X seconds, i.e. in X seconds you want to load another page.

Solution

<html>
<head>
<title>Title of the Page</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.example.com">
<link rel="stylesheet" type="text/css" href="assets/style.css" />
</head>
<body>
...
</body>
</html>

What we need here is line 5:

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.example.com">

Meaning: you will be redirected immediately (in 0 seconds) to http://www.example.com. You can change 0 to X, which means that redirection will be done in X seconds (where X is a positive integer).

Credits

I found this tip here.

About these ads
Categories: html Tags: ,
  1. Will
    May 11, 2011 at 01:34

    Hey, who’s to say this does any good. Do a wget -r onsite.com and it gets index.HTML.. Add the meta refresh to point at index.php, it won’t (wget) be able to recursively -r download your onsite.com. How would you fix this wget not parsing this?

    • May 11, 2011 at 02:17

      I couldn’t say I fully understood you… If you mean what it’s good for, then here is an example: I moved a project to a new place but at the old address I left a simple HTML page that informed the visitor that the project has moved and redirected the user to the new place in X seconds.

  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 73 other followers

%d bloggers like this: