htaccess Redirect Generator

Build Apache redirect rules for your .htaccess file. Redirect a single URL, a whole directory, or canonicalize to www, non-www or HTTPS, then copy the ready-made mod_rewrite rules. Free and instant in your browser.

.htaccess rules
.htaccess
Redirect 301 /old-page https://example.com/new-page

Paste into the .htaccess file in your site root. mod_rewrite must be enabled.

How it works

  1. 1

    Choose the redirect type

    Pick a single URL, a directory move, force www or non-www, or force HTTPS for the whole site.

  2. 2

    Fill in the details

    Enter the from and to paths and choose a 301 or 302, or enter your bare domain for the canonical options.

  3. 3

    Paste into .htaccess

    Copy the rules and add them to the .htaccess file in your site root, with mod_rewrite enabled.

Instant & 100% private — nothing is uploaded

Everything runs locally in your browser. Your code, text and files are processed on your own device and are never sent to a server — so there are no upload waits, no size limits from us, and nothing is ever stored or logged.

Frequently asked questions

When should I use 301 versus 302?
Use a 301 for a permanent move: it tells browsers and search engines the new URL is the lasting one, and it passes ranking signals along. Use a 302 only for a temporary redirect you intend to undo, such as a maintenance page, because it tells clients to keep using the original URL.
What is the difference between forcing www and forcing HTTPS?
They solve different canonical problems. Forcing www (or non-www) makes the site answer on a single hostname so example.com and www.example.com do not split your traffic. Forcing HTTPS upgrades insecure http requests to https. Many sites apply both, and the rules can sit together in one .htaccess.
Why are my redirects not working?
The usual causes are that mod_rewrite is not enabled, that AllowOverride is not set so Apache ignores the .htaccess, or that an earlier rule already matched and stopped processing. Order matters: put canonical rules near the top, and clear your browser cache, since 301s are cached hard.
Do these rules work on Nginx?
No. .htaccess and mod_rewrite are Apache features. Nginx uses its own rewrite and return directives in the server config, with a different syntax. These rules are for Apache or compatible servers such as LiteSpeed that read .htaccess.