Automatically redirecting visitors to another page

Automatically redirecting visitors to another page cover image
  1. Home
  2. HTML
  3. Automatically redirecting visitors to another page

It might so happen that during the web site maintenance process, you might rename a page or move it to another location. One of your kind visitors (rare!) informs you that he/she stumbled on this page and it shows a “404 page not existing error”.
Think about other users who have ‘bookmarked’ this page or worse still, search engines that have indexed this page.

A remedy for this problem would be to use an automatic redirection and we employ the <META> tag to accomplish this job.

Using the http-equiv and content attributes with appropriate values, we can set up this redirection.

<meta http-equiv="refresh" content="10; url=somepage.html">

The <meta> tag has to be included in the HTML head. The content attribute takes two values. The first specifies the number of seconds for the page to refresh and the second is the page URL address. (Note: These two values are enclosed in only ONE pair of quotes and separated by a colon).

The code above redirects the user to somepage.html in 10 seconds.

It is also wise to include a link to the new page in the HTML body section for older browsers that do not recognize the <meta> tag, something like:

The page has been moved <a href="newlocation.html">here</a>
HTML