.htaccess Redirect Generator

Pick what you want to redirect, fill in the addresses, and copy the lines into your .htaccess file.

What do you want to redirect?
Paste at the top of .htaccess, above "# BEGIN WordPress"

After saving, test the old address with the Redirect Checker. Keep a copy of your old .htaccess: a typo can take the site down (error 500), and putting the old file back fixes it.

Runs entirely in your browser: 0 bytes uploaded. Your files and text never leave your device. Privacy

When to use .htaccess redirects

.htaccess is a settings file that Apache and LiteSpeed servers read on every request. A redirect there runs before WordPress loads, so it is fast and works even for pages that no longer exist. Most shared hosting (cPanel, LiteSpeed) supports it. Nginx does not read .htaccess; there the rules go in the server config.

Which redirect type?

  • 301: moved for good. Search engines move the old page's ranking to the new one. Use this almost always.
  • 302: temporary. Search engines keep the old URL.
  • 308 / 307: like 301 / 302, but the browser must repeat a form submission (POST) at the new address. Only needed for forms and APIs.

How to add the rules safely

  1. Download a copy of your current .htaccess (cPanel File Manager: enable "Show hidden files").
  2. Paste the new lines at the top, above # BEGIN WordPress. WordPress rewrites its own block, so anything inside it can be lost.
  3. Save, then test the old addresses with our Redirect Checker. If the site shows "500 Internal Server Error", upload your copy again.

Redirect each old page to the most similar new page. Sending everything to the home page looks like a "soft 404" to Google and wastes the old page's value.

Prefer a plugin? WordPress redirect plugins work too, but they run after WordPress loads, so .htaccess is faster for large lists.

FAQ

Will these rules work on LiteSpeed?

Yes. LiteSpeed reads .htaccess and supports the same RewriteRule syntax as Apache.

Why RewriteRule and not "Redirect 301"?

"Redirect" matches the start of a path, so a rule for /old also catches /old-page. Our RewriteRule lines match the exact page, with or without a trailing slash, and sit well next to the WordPress rules.

Do query strings carry over?

Yes, by default the visitor's ?query is kept. If the old address you entered has its own ?query, we match on it and drop it from the new address.

Why does my site show "too many redirects"?

Usually the https rule and a proxy like Cloudflare disagree. Tick the Cloudflare/proxy box, or set Cloudflare SSL to "Full", and test again.

More free tools

Need a Tool We Don’t Have?

Tell us what you check on your sites every week. The most-requested tools get built first.