Skip to content
UniKit

Redirect generator

Generate 301 / 302 / 303 / 307 / 308 redirects for HTML meta refresh, JS location, nginx, Apache .htaccess, Node.js, PHP and Cloudflare _redirects, with SEO guidance for permanent vs temporary moves.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Status code
Output format

Generated code

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>Redirecting</title>
  <meta http-equiv="refresh" content="0; url=https://example.com/new-page">
  <link rel="canonical" href="https://example.com/new-page">
  <meta name="robots" content="noindex">
</head>
<body>
  <p>Redirecting to <a href="https://example.com/new-page">https://example.com/new-page</a>…</p>
</body>
</html>

What this tool does

  • Set up redirects after a redesign or domain move: pick 301 or 302 plus the target and get a snippet ready for nginx, Apache or Cloudflare.
  • On a static site with no backend, use an HTML meta refresh or JS location redirect and paste the small snippet into the old page.
  • Add a temporary redirect in a Node.js or PHP project — quoting is already escaped so special characters in the URL cannot break the syntax.
  • Unsure between permanent and temporary? The SEO advice spells it out: 301 and 308 pass ranking along, 302 / 303 / 307 keep it on the original page.

Example

Input

Target https://example.com/new, status 301, source path /old, format nginx

Output

location = /old {
    return 301 https://example.com/new;
}

The source path gets a leading slash and becomes an exact-match location block; the Cloudflare format instead produces a single line of source path, target and status.

Frequently asked questions

Should I use 301 or 302?

Use 301 when content has moved for good — search engines pass the original page's ranking to the new URL. Use 302 for maintenance, A/B tests or a temporary campaign entry point. Choosing wrong can throw away the old page's rankings or make a temporary redirect stick in browser caches.

Why do the HTML and JS formats have no status code?

Because a meta refresh and a JS location redirect run after the page has loaded, when the HTTP response has already gone out as 200 — there is no status code left to set. Crawlers may treat it as 200, so production sites should configure redirects at the server or CDN layer.

Which formats support a delay?

Only HTML, JS, Node.js and PHP, since they run as page or server code. nginx, Apache and Cloudflare are pure configuration with no delay capability, so a delay you enter is not reflected in their output.

Can the target be a relative path?

No. The target must be a full http or https URL; entering /new-page or new-page reports that it must start with http:// or https://, and other schemes such as ftp: are rejected too.

Is the generated code escaped safely?

Yes. HTML escapes ampersands, quotes and angle brackets; JS strings escape backslashes, quotes and newlines and write < as \x3c; PHP uses a single-quoted string with escaped quotes. Special characters in the target URL cannot break the syntax or inject code.

Keywords:redirect重定向301302307308meta refreshnginxhtaccesscloudflareseo 跳转

Related tools