How to Redirect a Web Page in HTML

To tell search engines and website visitors that your web page has permanently moved to a new location with an equivalent content use a 301 redirect. The code “301” is interpreted as “moved permanently”. (Learn more about HTTP Status Codes).

How to redirect to another URL

The simplest way to redirect to another URL is to use an HTML <meta> tag with the http-equiv parameter set to “refresh”. The content attribute sets the delay before the browser redirects the user to the new web page. To redirect immediately, set this parameter to “0” seconds for the content attribute.

<meta http-equiv="Refresh" content="0; url='https://www.w3docs.com'" />

If you want your redirection to occur in an exact time, just specify your preferred parameter (in seconds) for the content. Let’s consider an example, where we set "7" seconds as redirection time.

Some browsers don't render the <meta> refresh tag correctly, so before the next page loads, the user can see a flash as a page.
<meta http-equiv="refresh" content="7; url='https://www.w3docs.com'" />

Some old browsers don't refresh correctly when you add a quick link. In that case, you can add an anchor link to let the user follow.

Example of redirecting a web page:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="refresh" content="7; url='https://www.w3docs.com'" />
  </head>
  <body>
    <p>Please follow <a href="https://www.w3docs.com">this link</a>.</p>
  </body>
</html>

Learn more about redirecting web pages with JavaScript, PHP, Apache and Node.js.


Do you find this helpful?

Related articles