Tools / htaccess Redirect Generator

htaccess Redirect Generator

Generate Apache redirect rules for a cPanel-style .htaccess file. Add 301 or 302 redirects, force HTTPS and settle on a canonical www host, then copy a single mod_rewrite block.

Paste this near the top of the .htaccess file in your site root, above any WordPress or framework block. Back up the original file first.

Frequently asked questions

Where do these rules go?

Near the top of the .htaccess file in your site root, above any WordPress or framework block, because the first matching redirect wins. Back up the original file before you paste anything in.

301 or 302?

Use 301 when the move is permanent — it passes ranking signals and gets cached by browsers. Use 302 for temporary moves such as a campaign page or a short maintenance detour.

Can I redirect a URL with a query string?

Yes. Paste the full path including `?id=12` and the generator adds a matching RewriteCond, then appends a trailing `?` to the target so the old query string is not carried over.

Do I need to enter my domain?

No. The HTTPS and www rules use Apache's own %{HTTP_HOST} variable, so the same block works on staging and production without edits.

Why is everything wrapped in IfModule?

If mod_rewrite is disabled on the server, an unguarded RewriteEngine line returns a 500 error. The IfModule wrapper makes the block inert instead.

Let's build something you're proud of

I help businesses launch, optimize and maintain their online presence, from code to SEO.

Let's talk

Related tools