What is a redirect?
A redirect — also called URL redirection, or just "redirecting" — automatically sends visitors and search engines from one URL to another, without them clicking a new link. The server responds with a 3xx status code and a Location header pointing at the destination, and the browser follows it immediately, before rendering anything from the original URL. Redirects are the standard way to handle a moved page, a domain change, or making sure every variant of a URL — with or without www, over http or https — lands on one canonical address.
How this generator works
Pick a redirect type, fill in the paths or domains involved, and this tool writes the matching config for both an Nginx server block and an Apache .htaccess file. Everything runs in your browser — nothing is sent to a server.
Where does each snippet go?
- Nginx — inside the relevant
server { }block in your site's config file (commonly under/etc/nginx/sites-available/), then reload withnginx -s reloadafter testing the config withnginx -t. - Apache — in a
.htaccessfile in the site's document root, or inside a<VirtualHost>block in the main config..htaccessrequiresAllowOverride All(or at leastAllowOverride FileInfo) andmod_rewrite/mod_aliasenabled.
Redirect codes and types: 301 vs 302 vs 307 vs 308
The 3xx status code sent with a redirect tells browsers and search engines what kind of move it is — permanent or temporary, and whether the request method has to stay the same:
| Code | Meaning |
|---|---|
301 | Permanent redirect. Search engines transfer ranking signals to the new URL; browsers may cache it long-term. Use this for URLs that have moved for good. |
302 | Temporary redirect. Signals the move isn't permanent — search engines keep indexing the original URL. Use for A/B tests, maintenance pages, or short-lived moves. |
307 | Temporary redirect that explicitly preserves the HTTP method and request body (a POST stays a POST). The modern, spec-correct version of 302 for non-GET requests. |
308 | Permanent redirect that explicitly preserves the HTTP method and body — the 307 of the 301/302 pair. |
Frequently asked questions
Does this tool apply the redirect for me?
No — it only generates the config text. You still need to paste it into your Nginx or Apache config file and reload/restart the web server for it to take effect.
What's the difference between a redirect and a rewrite rule?
A redirect sends the browser a 3xx status code and a new URL — the address bar changes and the browser makes a fresh request, which is what every rule on this page generates. A rewrite rule is different: it changes which file or backend the server serves internally, but the address bar and the status code returned to the browser (usually 200) don't change. Nginx's rewrite directive and Apache's RewriteRule can do either — add a redirect flag like permanent or [R=301] and it redirects; leave it off and it rewrites silently instead.
Why does the "wildcard" option matter?
Without it, the rule matches one exact path only (e.g. /old-page). With it, the rule matches everything under a path (e.g. /old-section/anything/here) and carries the remaining part of the URL over to the new location — useful when you're moving a whole section of a site rather than a single page.
Why does my redirect need to preserve the query string or method?
A plain redirect drops nothing by default in these snippets — Nginx's $request_uri and the wildcard capture groups include the query string. If a request is a form submission (POST) that must stay a POST after redirecting, use 307 or 308 instead of 301/302, which some clients silently turn into a GET.
Do I need mod_rewrite for a simple path redirect on Apache?
No — a single exact-path redirect only needs mod_alias's Redirect directive, enabled by default on most Apache installs. Wildcard redirects, HTTPS forcing, and www/domain rewrites use mod_rewrite, which is common but not always enabled — check with apache2ctl -M | grep rewrite.
Is this the same as "website forwarding" from my domain registrar?
Not quite. Many registrars (GoDaddy, Namecheap, and others) offer a one-click domain or website forwarding feature that does something similar — sending visitors to a new URL — but it runs on the registrar's own servers, with no control over the redirect type or which paths it applies to. The rules generated here run on your own Nginx or Apache server, so they're more precise (exact paths, wildcards, specific status codes), but require you to have access to that server's config.
I want an HTML redirect instead of a server one — do you have that?
That's a meta refresh — an HTML <meta http-equiv="refresh"> tag that redirects the page after it loads, with no server config needed. It's generally the weaker option (see our meta refresh guide for why), but if a server-side redirect genuinely isn't available to you, that's where to start instead.