Free .htaccess Redirect Rule Generator

Generate safe .htaccess redirect rules in seconds: force HTTPS, www or non-www, trailing slashes, index.php removal, domain moves, 301 redirects and 410s – in single-hop rules that avoid chains and loops.

100% freeNo sign-upStep-by-step fixesDownload .htaccess rules
Only for a domain change. Every old URL is sent to the same path on your domain.
Use 410 as target for pages that are gone for good. Paths are matched with and without a trailing slash.

What is an .htaccess Redirect Rule Generator?

An .htaccess redirect generator writes Apache/LiteSpeed rewrite rules for you. You choose your preferred domain version, HTTPS and trailing-slash style and list old and new URLs – the tool creates tested rules that redirect every variant to the right URL in one hop.

A single typo in .htaccess can take your site offline or create redirect loops. Hand-written HTTPS and www rules also often create two-hop chains. This generator escapes special characters, flattens chained redirects, catches loops and puts the rules in the right order.

What the .htaccess Redirect Rule Generator checks

The generator checks your input for loops, duplicates and chains, and gives you a file you can copy or download.

HTTPS and www in one hop

Every http/www variant goes straight to your main URL.

Individual 301 redirects

Old path to new URL, with or without trailing slash.

410 Gone

Tell Google deleted pages are gone for good.

Domain moves

Send every URL of an old domain to the same path on the new one.

Trailing slash and index.php

Consistent URLs without duplicates.

Loop and chain protection

Detects self-redirects, flattens chains, escapes special characters.

How to use the .htaccess Redirect Rule Generator

Click Load Example above to see a real result first.

Enter your domain

Choose www or non-www, HTTPS and the trailing-slash style.

Add individual redirects

One per line: old path, a space, then the new URL or 410.

Click “Generate Rules”

Fix any warnings shown above the code.

Install and test

Paste above # BEGIN WordPress, save, then test with the Redirect Checker.

Common problems and how to fix them

ProblemWhy it mattersHow to fix it
HTTPS and www rules in two stepsTwo-hop redirect chain.Use one combined rule per variant.
Rules below # BEGIN WordPressWordPress handles the URL first.Place redirects above the WordPress block.
Redirect to itselfInfinite loop.Check targets – the generator blocks these.
Special characters not escapedRule matches the wrong URLs.Escape dots and brackets – done automatically.
CDN + Force HTTPSRedirect loop.Tick the CDN/proxy option.

Frequently asked questions

Where is the .htaccess file?

In the root folder of your website (public_html on most hosts). It is hidden – enable “show hidden files” in your file manager.

Does this work on Nginx?

No. .htaccess only works on Apache and LiteSpeed servers. Nginx uses its own configuration – ask your host to convert the rules.

Should I use a plugin or .htaccess?

Plugins like Rank Math Redirections are easier to manage. .htaccess rules run before WordPress loads, so they are faster and work even if WordPress is down.

What is the difference between 301 and 410?

301 sends visitors and Google to a new URL. 410 tells them the page is gone for good, so Google removes it faster.

What if my site breaks after saving?

Restore the backup copy of .htaccess. A 500 error usually means a syntax error or a server that does not support mod_rewrite.

Related free tools

Built and maintained by the AM Digital Marketing Agency SEO team. Last updated: .

Want us to fix it for you?

Our team fixes technical SEO issues, speed and indexing problems – and optimizes your site for Google, AI Overviews and ChatGPT.

View SEO Services