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.
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.
Every http/www variant goes straight to your main URL.
Old path to new URL, with or without trailing slash.
Tell Google deleted pages are gone for good.
Send every URL of an old domain to the same path on the new one.
Consistent URLs without duplicates.
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
| Problem | Why it matters | How to fix it |
|---|---|---|
| HTTPS and www rules in two steps | Two-hop redirect chain. | Use one combined rule per variant. |
| Rules below # BEGIN WordPress | WordPress handles the URL first. | Place redirects above the WordPress block. |
| Redirect to itself | Infinite loop. | Check targets – the generator blocks these. |
| Special characters not escaped | Rule matches the wrong URLs. | Escape dots and brackets – done automatically. |
| CDN + Force HTTPS | Redirect 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.