.htaccess Redirect Generator

Add one or more redirect rules, optionally force HTTPS and pick a canonical www/non-www version, and copy the resulting .htaccess block.

How to use it

  1. Enter the old path and where it should redirect to for each rule.
  2. Turn on HTTPS or www canonicalization if you need them.
  3. Copy the output and paste it into your site's .htaccess file, above any existing rewrite rules.

How it works

Simple redirects use Apache's mod_alias Redirect directive. HTTPS and www canonicalization use mod_rewrite conditions, since they need to check the current protocol and host before deciding whether to redirect.

Limitations

This assumes your host runs Apache with mod_rewrite and mod_alias enabled, which is standard on Hostinger-style shared hosting. It won't help if your host uses Nginx instead, which reads a different configuration format entirely.

Frequently asked questions

301 or 302 — which should I use?
Use 301 (permanent) when a page has moved for good — search engines will transfer its ranking to the new URL. Use 302 (temporary) if the move might be reversed, like during a short-term promotion.
Where does this code go?
Into the .htaccess file in your site's root folder (the same place as index.php). If the file doesn't exist yet, you can create a plain text file named exactly .htaccess.
Will this break my site if I get it wrong?
A bad rewrite rule can cause errors, so always keep a backup of your existing .htaccess before pasting in new rules, and test on a staging copy if you have one.
Does this handle rewriting query strings?
No — this generator covers simple path-to-path and path-to-URL redirects plus HTTPS/www canonicalization. Complex query-string rewriting needs hand-written mod_rewrite rules.