Free .htaccess Redirect Generator

Free .htaccess redirect generator for 301 and 302 redirects, domain moves, www or non-www, HTTP to HTTPS and trailing slashes, plus matching Nginx rules.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow to Set Up 301 Redirects With .htaccess (and Nginx) →

About the .htaccess Redirect Generator tool

Redirects protect your traffic and search rankings whenever URLs change. Moving to HTTPS, choosing between www and non-www, renaming a page or switching to a new domain all need proper 301 redirects, or visitors land on errors and Google loses track of your pages. On Apache hosting these rules go in the .htaccess file, but mod_rewrite syntax is unforgiving. This .htaccess redirect generator writes the rules for you.

Enter your domain and switch on what you need: force HTTPS, redirect www to non-www or the reverse, always add or remove the trailing slash, and send an entire old domain to the new one while keeping every path. Add as many single-page redirects as you like, each with its own 301 permanent or 302 temporary code. Old paths match with or without a trailing slash, and targets can be a local path or a full URL.

Many sites now run on Nginx, so the tool also produces equivalent Nginx server blocks and location rules in a second tab. Copy or download either version. The code is generated in your browser, and nothing is sent to a server.

How to use .htaccess Redirect Generator

  1. Type your domain and choose whether site-wide redirects should be 301 Permanent or 302 Temporary.
  2. Under “Site-wide rules”, switch on “Force HTTPS” and choose your www handling and trailing slash preference.
  3. If you moved domains, switch on “Redirect an old domain to your domain” and enter the old domain.
  4. Add each changed URL under “Single page redirects” with “Add redirect”, filling in the old path, new path and code.
  5. Open the “Apache .htaccess” or “Nginx” tab, then click “Copy” or “Download” and add the rules to your server.

Features

HTTPS and www in one go

Force HTTPS and pick a preferred host with rules ordered to avoid redirect loops.

Whole domain migration

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

Unlimited page redirects

Map old URLs to new paths or external URLs with a per-rule 301 or 302 choice.

Trailing slash control

Consistently add or remove the trailing slash without touching real files or folders.

Nginx equivalent

Get matching Nginx server and location blocks for the same redirects.

When to use it

  • Force HTTPS after installing a free SSL certificate on shared hosting.
  • Merge www and non-www versions of a site to consolidate SEO signals.
  • Redirect old blog URLs after changing the permalink structure.
  • Move a business to a new domain without losing Google rankings.
  • Set up a temporary 302 redirect for a seasonal sale page.

Frequently asked questions

What is the difference between a 301 and a 302 redirect?

A 301 is permanent and tells search engines to transfer rankings to the new URL. A 302 is temporary and keeps the original URL indexed. Use 301 for moves and 302 for short-term changes.

Where is the .htaccess file?

It is in your website’s root folder, often public_html. It is hidden because the name starts with a dot, so enable “show hidden files” in your file manager or FTP client.

Will these rules work on Nginx?

No. Nginx does not read .htaccess files. Use the Nginx tab instead and add the blocks to your server configuration, then reload Nginx.

Why is my site showing “too many redirects”?

This usually means two rules keep sending visitors back and forth, often because a CDN such as Cloudflare already handles HTTPS. Remove duplicate rules or change the CDN’s SSL setting to Full.

Are query strings kept when redirecting?

Yes. With these mod_rewrite and Nginx rules, any query string on the old URL is passed on to the new URL automatically.

How can I test my redirects?

Open the old URL in a private browser window, or use a redirect checker or curl -I to see the status code and Location header. Start with 302 while testing and switch to 301 once everything works.

Related tools