How to Use The Meta Tag to Redirect an HTML Page

Meta Tag to Redirect

Ideally, you can use the Meta Tag to redirect an HTML web page to another. This method does not require JavaScript such as this method, neither does it require any server redirects as shown here using .htaccess.

Web page redirection is where you clicked a URL, or typed in a URL in your web browser to reach a particular page or website but instead, you are directed to another page or site. This is a feature built into web browsers by design.

Common use-cases for using the Meta Tag to redirect to another page is where the old page still exists but you could be running a temporary campaign and want to redirect users there.

Another good use of this method is in situations where you have a change of domain name and want visitors familiar with the old domain to be redirected to the new one automatically.

Read Also  PHP 8.0.0 Beta 1 Release Available for Development Testing

You may also want to use this Meta Tag method when you want to delay the redirect for some particular reason.

This method is not ideal for situations where the old page no longer exists. To implement these sorts of redirects you would have to use a server-side solution.

Using a META Tag to Redirect Your Site

To use a META Tag to redirect your site can quite easily be done using the http-equiv attribute to provide an HTTP header for the value of the content attribute.

All you need to do is supply the destination url or page and optionally the delay in seconds. Leavinf out the seconds implies an immediate redirect.

  • http-equiv: Set the value to refresh
  • content: optionally add the delay in seconds followed by a semi-colon. Add the target by entering url=the_target_url

See this example of how it is used. Here we use a delay of 5 seconds.

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Meta Tag Redirect</title>
      <meta http-equiv="refresh" content="5;url=https://brightwhiz.com"/>
   </head>
   <body>
      <p>This text should display for about 5 seconds.</p>
   </body>
</html>

Conclusion

As mentioned above, you do not have to exclusively use the HTML Meta Tag to redirect to another site. You can also use a JavaScript of jQuery option or even a server-side option such as the PHP, Apache configuration, or .htaccess methods.