HTACCESS Redirect Generator

Generate Apache .htaccess or nginx redirect rules

Create redirect rules for Apache (.htaccess) or nginx: individual pages (including old URLs with query strings), force HTTPS, www or non-www in a single hop, trailing slashes, and moving to a new domain.
Try an example:

Output will appear here...

About HTACCESS Redirect Generator

How it works

  1. Choose your web server (Apache or nginx) and the kind of redirect.
  2. For individual pages, list each old path and its new URL. Full old URLs are trimmed to their path; old URLs with ?query=strings get a special rule, because simple redirects ignore query strings.
  3. "Exact page only" redirects just that address (with or without a trailing slash); "everything below it" also moves /old/sub-page to /new/sub-page.
  4. HTTPS + www rules redirect every variant in a single hop, which is faster and better for SEO than chaining two redirects.

What you need

  • Apache: access to the .htaccess file in your site's root folder (mod_rewrite enabled - most hosts have it).
  • nginx: access to your server configuration and permission to reload nginx.

Tips

  • Use 301 for permanent moves so search engines transfer rankings; 302 only for temporary changes.
  • Back up your existing .htaccess first - a typo can take the whole site down with a 500 error.
  • Behind Cloudflare or a load balancer, Apache may think every request is http; tick the proxy option to avoid a redirect loop.
  • After deploying, test the old URLs with our Redirect Checker.

Limitations

  • Redirect rules are tried in order; if your .htaccess already has rules (e.g. WordPress), put these above the "# BEGIN WordPress" block.
  • For nginx, SSL certificate lines are left as comments - copy them from your existing server block.
  • Other servers (IIS, Caddy, Netlify, Vercel) use different syntax.

Runs in your browser. Everything is generated in your browser.

Frequently asked questions

What is an .htaccess file?+

A configuration file for Apache web servers that applies to the folder it is in and all folders below. It is commonly used for redirects, HTTPS and caching rules. Its name starts with a dot, so it may be hidden in your file manager.

Why did my site show a "too many redirects" error?+

Usually a loop: e.g. Cloudflare connects to your server over http while your rule forces https. Tick "Site is behind Cloudflare or a load balancer", or set Cloudflare SSL to "Full".

Redirect vs RedirectMatch vs RewriteRule?+

Redirect matches a path prefix, RedirectMatch uses a regular expression (we use it for exact matches), and RewriteRule (mod_rewrite) can also look at the host, HTTPS and query string.

Does nginx read .htaccess files?+

No. nginx is configured centrally in its server blocks, so choose nginx as the web server to get the equivalent rules.