Written by the Utiliby editorial team · Last updated October 14, 2026 · Rules and formulas reviewed October 2026
What this free .htaccess redirect generator does
Moving a page, changing a domain, switching to HTTPS or choosing between www and non-www all lead to the same job: telling the server to send visitors, and search engines, from an old address to a new one. On an Apache server that means writing rules in a file called .htaccess. The syntax is easy to get wrong, and one misplaced character can cause a loop or take the site down.
This free online redirect generator writes the rules for you. Choose HTTPS and www settings, trailing slash handling and index file removal, move an old domain, and paste a list of page redirects with 301, 302, 307, 308 or 410 codes. Switch to Nginx for server rules. A built-in test follows any URL through your rules and shows every step, so you can find chains and loops before you go live. It is free, private and needs no sign-up.
How to create redirect rules in five steps
- Enter your domain. Use the bare domain, such as example.com.
- Choose the main address. Pick www or non-www, and tick Force HTTPS.
- List page redirects. Write each old path, a space and the new path. Add a code at the end when you need something other than 301.
- Test it. Enter a few old URLs in the test box and check that each takes one step.
- Add it to your server. Back up your current file, paste the rules into .htaccess or your Nginx configuration, and check the result in a browser.
Which redirect code should you use?
| Code | Meaning | Use it when |
|---|---|---|
| 301 | Moved permanently | A page or site has a new home for good |
| 302 | Found, temporary | A short-term move, such as a test or a sale page |
| 307 | Temporary, keeps the method | A temporary move for forms and APIs |
| 308 | Permanent, keeps the method | A permanent move for forms and APIs |
| 410 | Gone | A page was removed on purpose with no replacement |
For nearly all website moves, 301 is correct. Use a temporary code only when the original address will come back.
HTTPS, www and one main address
Search engines treat http://example.com, https://example.com, http://www.example.com and https://www.example.com as four separate addresses. If all four open your site, you have four copies and your links and signals are split between them. Pick one main address, send the others to it with a permanent redirect, and use the same address in your sitemap, canonical tags and internal links. This tool writes one combined rule so that any wrong version goes to the main one in a single step, instead of passing through two redirects.
If your site is behind Cloudflare or another proxy, the server may see every request as plain HTTP even though visitors use HTTPS. In that case a normal HTTPS rule creates a loop, so tick the proxy option to test the forwarded protocol instead.
Moving to a new domain
- Map every page. Redirect each old URL to its equivalent on the new domain, not just to the home page.
- Use 301. Keep the path so old-site.com/page goes to new-site.com/page.
- Keep the old domain. Renew it and keep the redirects for at least a year.
- Update your signals. Use the change of address tool in Search Console, update your sitemap and internal links.
- Watch the results. Check crawl errors and traffic for several weeks.
Common redirect mistakes
- Chains: A to B to C. Point A straight to C.
- Loops: a rule that sends a page back to itself or two rules that point at each other.
- Sending everything to the home page, which search engines may treat as a soft 404.
- Using 302 for permanent moves, so signals may not pass.
- Forgetting the query string, or keeping one you meant to drop.
- Editing the live file without a backup.
- Leaving internal links on old URLs, which forces every visit through a redirect.
Testing your redirects
The test box takes a URL and applies your rules in the order the server would: old domain, page redirects, then the main host and HTTPS, index files and trailing slashes. It repeats until no rule matches and lists each step with its code. A good result is zero or one step. Two or more steps are shown as a chain, and a repeating address is flagged as a loop. The simulation cannot see files on your server, so it treats every address as a normal page. After you upload the rules, check real URLs in a browser or with a header checker.
Troubleshooting
- Too many redirects: remove the last rules you added, and tick the proxy option if you use Cloudflare.
- 500 internal server error: a rule has a syntax problem, or mod_rewrite is off. Restore your backup and ask your host.
- Nothing happens: check that .htaccess is in the site root and that your host allows overrides.
- Old URLs still show in search: Google needs time to recrawl. Submit the new sitemap.
- WordPress rules clash: place custom redirects above the lines between # BEGIN WordPress and # END WordPress.
Privacy and how it works
Your browser turns the settings you choose into rewrite rules and runs a small simulation of them on the URL you test. Nothing is uploaded, stored or logged. Print / save summary creates a short report from your entries, and the rest of the page is not included in the print.
Related free tools
Use these free online tools together with this one:
- Control what crawlers can access with the robots.txt generator.
- Point visitors to the right language version with the hreflang tag generator.
- Set indexing rules for a single page with the meta robots tag generator.
- Schedule server tasks with the cron expression generator.
- Set up DNS records for email with the DMARC record generator.
- Track visits to a redirected link with the UTM link builder for social campaigns.
Frequently asked questions
What is an .htaccess redirect generator?
It is a tool that writes redirect rules for the .htaccess file used by Apache web servers. You enter the old and new addresses and settings such as HTTPS and www, and the tool produces rules you can paste into your file.
How do I create a 301 redirect in .htaccess?
Add a line like RewriteRule ^old-page/?$ /new-page [R=301,L] after RewriteEngine On. Enter your old and new paths in the box above and the tool writes the rule for you.
What is the difference between 301 and 302 redirects?
A 301 is permanent and tells search engines to pass the old address to the new one. A 302 is temporary and tells them to keep the old address. Use 301 for moves that will stay, such as a new URL or a new domain.
What are 307 and 308 redirects?
They are the modern equivalents of 302 and 301 that also keep the request method, such as POST. For ordinary pages, 301 and 302 work fine.
How do I force HTTPS with .htaccess?
Tick Force HTTPS and enter your domain. The tool writes a rule that sends every HTTP request to the HTTPS address. If your site is behind Cloudflare, tick the proxy option so the rule uses the forwarded protocol and avoids a loop.
How do I redirect non-www to www?
Choose Always use www as the main address. The tool adds a rule that sends the bare domain to the www version in a single step, together with HTTPS if you chose it.
What is a redirect chain and why is it bad?
A chain is when one redirect leads to another before the final page. Each step adds delay, and some crawlers stop after a few steps. The test box shows every step so you can fix them.
What is a redirect loop?
A loop is when redirects send a visitor back and forth forever, and the browser shows an error such as too many redirects. The tool warns when a rule points to itself and when it finds a loop in the test.
How do I redirect a whole folder?
End the old path with /* and give a destination, for example /blog/2019/* /blog/. Everything under the old folder is sent to the new one, and the rest of the path is kept.
How do I redirect an old domain to a new domain?
Enter your new domain at the top and the old domain in the move field. The tool keeps the path, so old-site.com/page goes to new-site.com/page. Keep the old domain registered and the redirect in place for at least a year.
What does 410 mean?
A 410 status says a page is gone on purpose. Search engines may drop it from results faster than a 404. Use it for removed pages that have no replacement.
Does the tool support Nginx?
Yes. Choose Nginx and you get server blocks and location rules instead of .htaccess lines. Nginx does not use .htaccess files, so paste the rules into your server configuration and reload Nginx.
Where is the .htaccess file?
It sits in the root folder of your site, often called public_html or www. It is a hidden file because its name starts with a dot, so turn on hidden files in your file manager.
Will redirects hurt my SEO?
Redirects done correctly pass most of the value of the old page to the new one. Problems come from chains, loops, redirecting many pages to the home page and leaving internal links pointing at old addresses.
How do I remove index.php or index.html from URLs?
Tick the option. The tool writes a rule that redirects /index.php and /index.html to the clean folder address, which prevents duplicate versions of the same page.
Is my data uploaded anywhere?
No. The tool runs in your browser. The paths and domains you enter are not sent to Utiliby or to any other server.
What can I print or save from the page?
Print / save summary gives a short report with your settings and test results. Download file saves the rules as .htaccess or an Nginx file. Copy code puts them on your clipboard.
Sources and further reading
- Apache HTTP Server Documentation, mod_rewrite and Redirect directives (httpd.apache.org), for RewriteRule syntax and flags.
- Nginx documentation, the return and rewrite directives (nginx.org).
- RFC 9110, HTTP Semantics (rfc-editor.org), for the meaning of 301, 302, 307, 308 and 410.
- Google Search Central, Redirects and Google Search, for how redirects affect indexing.
- Google Search Central, Site move with URL changes, for domain move steps.
- Cloudflare Docs, Redirect loops and SSL modes, for proxy behavior.
Sources were consulted in October 2026. Standards and rules can change, so always check the official page for your situation.