This post will discuss how to set up a redirect from an HTML page without using JavaScript.

1. Using Meta Tag

You can redirect your website or its content using a META Refresh. The idea is to place the following in the head section of your HTML page:

<meta http-equiv="refresh" content="0; url=https://www.example.com" />

In the content parameter, https://www.example.com/ should be replaced with the actual web page link, and optionally you may increase the time interval (in seconds) between the page load and redirection.

Here’s a simple example demonstrating this, where a redirect happens to https://www.google.com/ on page load without any lapse:

2. Using 301 Redirect

Note that the use of meta refresh is discouraged by the World Wide Web Consortium (W3C). A better and preferred alternative to redirect a user to a different page is to use an HTTP status code, such as HTTP 301 or 302. We can achieve this with a custom rule in the Web server or a script installed on your Web server.

The following example set up a 301 redirect using a .htaccess file at the domain level.

 
To set up 301-redirect for individual pages, you can do this:

3. Using <body> tag – onload property

You can also set up a redirect using onload property of the HTML <body> tag. The page will then be redirected as soon as the DOM is loaded and the onload event is fired.

That’s all about redirecting from an HTML page without using JavaScript.