Redirect Code Generator (301, 302, 307, 308)
Write a page, folder, domain, HTTPS or www redirect for Apache, Nginx, IIS, Netlify, Cloudflare, Vercel, PHP, HTML meta refresh or JavaScript, with the right status code.
Many redirects at once on Apache, or old addresses with a query string? .htaccess Redirect Generator →
On Netlify a rule is skipped while a file still exists at the old path; add ! after the code (301!) to force it.
A meta refresh cannot send a status code. Google treats an instant (0-second) meta refresh as a permanent redirect and a delayed one as temporary.
JavaScript redirects need no jQuery: location.replace() is plain JavaScript and leaves no extra history entry. Google only sees them after rendering the page, so use them when no server-side option exists.
Browsers cache permanent redirects. Test with 302 first, then switch to 301; keep redirects in place for as long as possible — at least a year after a move.
Moving a page, a folder or a whole site means telling browsers and search engines where it went, and every platform writes that differently. This generator turns one redirect — a page, a folder with everything in it, a domain move, HTTP to HTTPS, or www to non-www and back — into ready code for Apache .htaccess, Nginx, IIS web.config, Netlify and Cloudflare _redirects files, vercel.json, PHP, an HTML meta refresh and JavaScript, with special characters escaped for each format.
How to use this tool
- Choose what to redirect.
- Fill in the old path and new address, the old and new domains, or your domain, depending on the choice.
- Pick the status code: 301 or 308 for permanent moves, 302 or 307 for temporary ones.
- Choose your platform (or keep all), copy the code into place and test the old address in a private window.
Formula
server rule: old URL → HTTP 301 / 302 / 307 / 308 + Location: new URL; meta refresh: content="0; url=…"; JavaScript: location.replace(new URL)
301 and 308 are permanent and 302 and 307 temporary; 307 and 308 also require the browser to repeat a POST as a POST. Server-side redirects work for every visitor and crawler. A meta refresh or JavaScript redirect only runs once the page loads, so use them on hosts where you cannot change the server configuration. Folder rules keep the rest of the path; page rules match the exact path.
Example
Moving /old to https://example.com/new permanently gives, for Nginx, location = /old { return 301 https://example.com/new$is_args$args; } — the $is_args$args part keeps any query string. Apache gets RedirectMatch 301 ^/old$ https://example.com/new, and Netlify and Cloudflare a one-line rule: /old https://example.com/new 301.
Frequently asked questions
Which redirect is best for SEO?
A server-side 301 or 308. Google treats both as permanent and moves the old page's signals to the new address. An instant meta refresh is also read as permanent, but JavaScript redirects are only seen after rendering, so keep them as a last resort.
301 or 308 — what is the difference?
Both are permanent. A 301 lets browsers change a POST into a GET when they follow it; a 308 must repeat the same method. For ordinary pages they behave the same; for form or API endpoints prefer 308 (or 307 if temporary).
Do I need jQuery for a JavaScript redirect?
No. window.location.replace("https://…") is built into every browser. It also replaces the current history entry, so the back button does not bounce the visitor into the redirect again.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/redirect-generator/
Cite or embed this tool
kakaoCalc. (2026, November 8). Redirect Code Generator (301, 302, 307, 308). https://kakao.mobile/tools/redirect-generator/
“Redirect Code Generator (301, 302, 307, 308).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/redirect-generator/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms