Is it possible to create a simple page with an HTML redirect so that when the page loads, it automatically takes the user to another URL?
I’m looking for the cleanest way to handle this using just HTML, no JavaScript if possible.
Would appreciate an example!
One of the cleanest ways to handle this is by using the tag inside the of your HTML.
It’s simple, widely supported, and doesn’t require any scripting:
html
Copy
Edit
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="3;url=https://example.com">
<title>Redirecting...</title>
</head>
<body>
<p>Redirecting you to the new page. If it doesn't happen automatically, <a href="https://example.com">click here</a>.</p>
</body>
</html>
This setup delays the redirect by 3 seconds, which is helpful for UX.
Just set content=“0;url=…” for an instant redirect.
If you’re working with HTTP headers on the server side (and can tweak your HTML server config), you might not even need to put the redirect in the HTML itself.
Instead, serve the page with a Location header and a 301/302 status code.
For example, in Apache you can set a redirect in .htaccess:
bash
Copy
Edit
Redirect 301 /old-page.html https://example.com/new-page.html
This approach is better for SEO and browser caching since it’s handled server-side.
It’s also invisible to the user in terms of markup.
@apksha.shukla In cases where the page is being served from a static host (like GitHub Pages or Netlify), you can combine HTML with fallback instructions.
One useful trick is to use the block to inform users in case scripting is disabled, even though the redirect is handled by meta:
html
Copy
Edit
<head>
<meta http-equiv="refresh" content="0;url=https://example.com">
</head>
<body>
<noscript>
<p>If you are not redirected, <a href="https://example.com">click here</a>.</p>
</noscript>
</body>
It keeps things graceful for browsers or users who disable auto-refresh behavior and gives a bit more accessibility consideration.