How to make an HTML file redirect to another URL
Quick answer
To make an HTML file redirect to another URL, put <meta http-equiv="refresh" content="0; url=https://example.com/new-page"> in its head section and a plain link to the new address in its body. Google Search reads an instant meta refresh as a permanent redirect. Where you control the server, use an HTTP 301 instead: Google calls that the best way.
Free plan: no credit card, 1 published page.
On this page
You have one HTML file, or an old address people still open, and you want everyone who lands there to end up at another URL. An HTML file can do that by itself, with one tag. This guide gives the file to copy, compares the tag with JavaScript and a server's 301, and lists the mistakes that leave visitors on a blank page.
The Google, MDN, Netlify, and Cloudflare pages quoted here were read on November 15, 2026. We ran every HTML sample on this page the same day in Chromium 156, Firefox 157, and WebKit 27.2 (Safari's engine), the builds Playwright 1.64 ships, on a Mac.
The file to copy
Save this as index.html, or under the name of the page you are replacing. Change the address in all 3 places.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>This page has moved</title>
<meta http-equiv="refresh" content="0; url=https://example.com/new-page">
<link rel="canonical" href="https://example.com/new-page">
</head>
<body>
<p>This page has moved to <a href="https://example.com/new-page">https://example.com/new-page</a>.</p>
</body>
</html>
Each line has a job:
- The
metatag does the redirect. MDN describes itscontentas the number of seconds until the page redirects, written as "a non-negative integer followed by;url=and a valid URL".0means at once. - The canonical link names the address you want in search results. Google lists both redirects and
rel="canonical"as "a strong signal" for which URL it treats as the main one. Some hosts rewrite this tag; Convika does, as the Convika section explains. - The link in the body is the fallback. A person or a program that doesn't follow the tag still gets the address. Google's redirect guide asks for the same thing: "let your users know that the page or its content has moved", with "a link pointing to the new page accompanied by a short explanation".
In our test, this file sent all 3 engines to the new address, with JavaScript on and with it off. Pressing Back went to the page before the redirect file, not to the file itself.
Meta refresh, JavaScript, or a 301
There are 3 ways to send a visitor on. They differ in where they run and in how Google reads them.
| Meta refresh, 0 seconds | JavaScript location.replace() | HTTP 301 from the server | |
|---|---|---|---|
| Where it lives | A tag in the HTML file | A script in the HTML file | The server's or host's settings |
| Needs server access | No | No | Yes |
| Works with scripts off | Yes, in our test | No | Yes; MDN: HTTP redirects "exist when there is not even a transmitted page" |
| How Google Search reads it | "Google Search interprets instant meta refresh redirects as permanent redirects" | Listed as permanent, with a warning: "Google might never see it if rendering of the content failed" | "The best way to ensure that Google Search and people are directed to the correct page" |
| Google's advice | "May be a viable alternative" when "server-side redirects aren't possible to implement on your platform" | "Only use JavaScript redirects if you can't do server-side or meta refresh redirects" | "We recommend that you use a permanent server-side redirect whenever possible" |
| Works for images, PDFs, and other files | No; MDN: "this method only works with HTML" | No; MDN: "this can't work on all resources" | Yes |
Google orders its redirect types "by how likely Google is able to interpret correctly", and says a server-side redirect "has the highest chance". For a permanent redirect of any type, Google says its indexing "uses the redirect as a signal that the redirect target should be canonical", meaning the new address is the one it shows. Google's page says nothing about PageRank or "link equity", so this guide doesn't either.
MDN gives the same order: "HTTP redirects are the best way to create redirections, but sometimes you don't have control over the server." It also warns against using both at once: "When possible, use HTTP redirects and don't add <meta> element redirects", because if someone later changes one and not the other, the two "will no longer be identical, which could cause an infinite loop".
If your host has redirect rules
Some static hosts take a rules file, so you get a real 301 without running a server:
- Netlify. Its docs say to "save a plain text file called
_redirectswithout a file extension to the publish directory", one rule per line, "the original path followed by the new path or URL". In anetlify.tomlrule, the status is "301 by default". - Cloudflare Pages. The same file name, with each line as
[source] [destination] [code?]. Cloudflare's docs give the default code as 302, a temporary redirect, so write301at the end of the line for a permanent one.
Convika has no redirect rules to set: it serves your HTML file as a static page. The redirect file above is the route there.
The JavaScript route
Use a script when the redirect depends on something only the browser knows, or when you want to carry the visitor's query string along. location.replace() loads the new address in place of the current page. MDN: "the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it."
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>This page has moved</title>
<script>
location.replace("https://example.com/new-page");
</script>
<noscript>
<meta http-equiv="refresh" content="0; url=https://example.com/new-page">
</noscript>
<link rel="canonical" href="https://example.com/new-page">
</head>
<body>
<p>This page has moved to <a href="https://example.com/new-page">https://example.com/new-page</a>.</p>
</body>
</html>
The noscript block covers a browser with JavaScript off: in our test with scripts disabled, all 3 engines followed its meta tag.
To pass on what came after the address, such as ?utm_source=mail or #pricing, change the script's one line:
<script>
location.replace("https://example.com/new-page" + location.search + location.hash);
</script>
Opened as old-page.html?utm_source=mail#pricing, this landed on https://example.com/new-page?utm_source=mail#pricing in all 3 engines. A meta refresh can't do this: its address is fixed text.
A delay with a message
To show a notice first, raise the number. This waits 5 seconds:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>We have moved</title>
<meta http-equiv="refresh" content="5; url=https://example.com/new-page">
</head>
<body>
<h1>We have moved</h1>
<p>You will go to the new page in 5 seconds. If nothing happens, open <a href="https://example.com/new-page">https://example.com/new-page</a>.</p>
</body>
</html>
Two things change with a delay:
- Google reads it as temporary. "Google Search interprets delayed
meta refreshredirects as temporary redirects", and for a temporary redirect it keeps showing the old page in results. If the move is for good, use0. - Some readers can't finish the message in time. MDN: people using a screen reader "may be unable to read through and understand the page's content before being automatically redirected", and its redirect guide says to "always set it to 0 for accessibility compliance". Keep the link in the message so nobody depends on the timer.
MDN adds that the timer "starts when the page is completely loaded", so a slow page waits longer than the number says. With a delay, Back behaved differently per engine in our test: Chromium and WebKit went back to the notice page, which then redirected again; Firefox skipped it.
Make the redirect file in 4 steps
1. Copy the code into a text editor
Paste the file to copy into Notepad, TextEdit in plain-text mode, or VS Code.
2. Put your address in all 3 places
Replace https://example.com/new-page in the meta tag, the canonical link, and the fallback link. Write the full address, starting with https://.
3. Save it with the right name
Save it as .html. On a host that serves a folder, the name decides which address redirects: index.html for the folder's own address, old-page.html for /old-page.html.
4. Open it and watch where you land
Double-click the file. Your browser opens it from disk and goes straight to the new address. Then put the file where the old address is, or publish it at a link, and open that address too.
Test it
- From your disk. A double-clicked file opens at a
file:///address, and the redirect still runs: in our test, all 3 engines went from a local file to the web address in the tag. - To read the file without leaving it. Open Convika's free HTML viewer, turn off Run scripts, and choose the file. The viewer keeps the page in a sandboxed frame, and with scripts off neither the meta tag nor the script fires, so you can check the fallback message and its link. With Run scripts on, the redirect runs inside the viewer's frame, and a destination that refuses to be framed doesn't show there; that's the frame, not your file.
- At its real address. Open the published address in a private window and check the address bar after it settles. Try it once on a phone.
- With the status line, if you set a 301. Run
curl -I https://example.com/old-pageand look for301and aLocation:header. A meta refresh page answers200, because the redirect is inside the page.
Common mistakes
- A relative address.
url=new-page.htmlis read from where the redirect file sits. Opened from disk, ours went tofile:///…/new-page.html, a file on the same computer. Write the fullhttps://address unless both pages always travel together. - A loop. Page A sends to B, and B sends back to A. Nothing stops it: in our test Chromium requested the two pages 864 times in 3 seconds, and no engine showed an error. Open the destination by itself first and make sure it stays put.
- A different address in the tag and in the link. After a later edit, the tag, the canonical link, and the fallback link drift apart. Search the file for the old address before you save.
- A script blocked by the page's host. A host or a preview that turns scripts off stops
location.replace(). Keep thenoscriptmeta tag and the plain link. - Expecting the old file to keep its place in Google. A redirect tells Google the new address is the main one. Google says old addresses can still show for a while: "This is normal and as users get used to the new domain name, the alternate names will fade away without you doing anything."
- Redirecting a PDF or an image. A meta tag lives in HTML, so it can't forward a file of another type. That takes a server's or host's redirect rule.
Two things that look like mistakes worked in all 3 engines in our test: a content value without the url= part (0; https://example.com/new-page), and the tag placed in the body. Google's guide says to place it "in the <head> element", so keep it there.
Publish the redirect file when you have no server
A redirect file needs an address before it can forward anyone. If you have no host, Convika publishes the file at a link:
- Drop the file into the upload box at the top of this page, or paste the code, and click Get my preview link. The preview is for checking the fallback message only: it runs no scripts and drops
meta refreshtags, so the redirect doesn't fire there. It works for 3 minutes. - Click Keep this page — free, no card and sign up. The page moves into your account as you uploaded it.
- Click Publish page. Under Who can open this page?, choose Public and click Next. The first time, click Publish free.
- Open the page's address, such as
yourname.convika.page, and check that you land on the new URL.
What Convika does and doesn't do for a redirect:
- It serves the file as a static page. The
metatag and the script run in the visitor's browser. We served both files with the security headers a published Convika page sends, and all 3 engines followed the redirect. We didn't run the test on a live Convika page. - It has no 301 and no redirect rules. You can't tell Convika to answer one address with another. The only redirect it makes itself is from a connected domain's address without
wwwto the one withwww. - It sets the canonical link to the page's own address. Convika replaces a
rel="canonical"tag in an uploaded page with the address it serves the page at. So on Convika, Google gets the instant meta refresh as its signal, not your canonical link. - It takes one
.htmlor.htmfile up to 2 MB, and runs no server code.
To change where the page sends people later, upload a corrected file as a new version of the same page; updating a page at the same address shows how. On Free, the page is Public and carries the Convika bar; an instant redirect sends visitors on as soon as the page loads. Pro ($12 a month) removes the bar and adds private links and passwords.
If the page you are moving is itself on Convika and you only want new content at the same address, you don't need a redirect at all: publish the new version there.
Frequently asked questions
How do I redirect an HTML file to another URL?
Put <meta http-equiv="refresh" content="0; url=https://example.com/new-page"> inside the file's <head>, with your own address after url=. Add a plain link to the same address in the body for anyone whose browser doesn't follow the tag. The browser goes to the new address as soon as the page loads.
Is a meta refresh redirect bad for SEO?
Not when the delay is 0. Google's redirect guide says "Google Search interprets instant meta refresh redirects as permanent redirects", and that a permanent redirect is a signal that the target should be the canonical URL. Google still ranks a server-side 301 first, as the type with "the highest chance of being interpreted correctly", so use that when your host allows it. A delayed meta refresh is read as temporary.
What is the difference between a meta refresh and a 301 redirect?
A 301 is an HTTP status the server sends before any page, with the new address in a Location header. A meta refresh is a tag inside an HTML page that the browser reads after the page arrives. A 301 works for every file type and needs server or host settings; a meta refresh needs only the file, and works only for HTML.
How do I redirect with JavaScript?
Call location.replace("https://example.com/new-page") in a script in the <head>. MDN says the current page then isn't saved in session history, so Back doesn't return to it. Google says to use a JavaScript redirect only if you can't do a server-side or meta refresh redirect, because it "might never see it if rendering of the content failed".
Can I redirect after 5 seconds?
Yes. Write content="5; url=https://example.com/new-page" and put a message with a link on the page. Google reads a delayed meta refresh as a temporary redirect, and MDN's redirect guide says to always use 0 for accessibility, so use a delay only when visitors need to read something first.
Does an HTML redirect work when I open the file from my computer?
Yes. In our test on November 15, 2026, Chromium 156, Firefox 157, and WebKit 27.2 all followed a meta refresh and a location.replace() from a file:/// page to a web address. A relative address in the tag points at another file on the same computer.
Why does my redirect page keep reloading?
The destination redirects back, so the two pages form a loop. MDN describes it: "there is a loop that will never be finished and no page will ever be found." Open the destination address by itself and check that it doesn't send you on again. A meta tag with a number and no address also reloads: MDN says content="300" "tells the browser to refresh the page after 5 minutes".
Can I redirect a page without access to the server?
Yes, with a meta refresh in the page itself. Google's guide names that case: "If server-side redirects aren't possible to implement on your platform, meta refresh redirects may be a viable alternative." If the old page is on a host you can no longer edit at all, nothing in a new file can forward its visitors.
Sources
- Redirects and Google Search (Google Search Central) (last updated April 14, 2026; read November 15, 2026)
- How to specify a canonical URL with rel="canonical" and other methods (Google Search Central) (read November 15, 2026)
<meta http-equiv>(MDN) (last modified April 20, 2026; read November 15, 2026)- Redirections in HTTP (MDN) (last modified August 27, 2026; read November 15, 2026)
- Location: replace() method (MDN) (last modified October 26, 2024; read November 15, 2026)
- Redirects and rewrites (Netlify Docs) (read November 15, 2026)
- Redirects (Cloudflare Pages docs) (last updated August 25, 2026; read November 15, 2026)
Next step
How to password protect an HTML page or website
A JavaScript password script leaves the password in the page source. To password protect an HTML page or link, encrypt the file or let a server check it.
Related articles
- How to share an HTML file as a link that opens on any phoneUpload the file to a host and send its link; email and Google Drive send the code. 8 hosts compared, from Netlify Drop to Convika, with 4 steps.
- Update your AI-made page without changing its link or QR codeFix a page you already shared: get the corrected HTML from your AI, upload it as the next version in Convika, preview it, and publish at the same link.
- How do I create a QR code for an HTML file?To convert an HTML file to a QR code, publish it at an address that stays, then click Show QR code and download a PNG. The code holds a link, not the file.
- file://error_page_loaded.html, code, or a blank page: why your HTML file won't displayfile://error_page_loaded.html is Chrome's error page on an iPhone or iPad, not your file. Why an HTML file shows code or a blank page, and each fix.
- Claude made my landing page. How do I get it live on my own domain?Host the HTML, add 2 DNS records, and wait for HTTPS. The steps on Convika Free, and what Vercel, Cloudflare Pages, GitHub Pages, and Netlify ask for.
- Free HTML hosting compared (2026)Netlify Drop, Cloudflare, GitHub Pages, Vercel, Tiiny Host, and 6 more free HTML hosts compared: sign-up, link expiry, custom domain, forms, stats, and badge.
Skipbox
Cheap & fast GitHub Actions runners, unlimited for $39 a month
Your own machine keeps Docker layers and package caches between jobs. Switch by changing one runs-on line.
Start a free Skipbox trial