.htaccess Redirect Generator

Htaccess Redirect generates the rules needed to move visitors between the www and non-www version of a domain. It is for Apache servers that use .htaccess files.

Remove Ads
Remove Ads
Remove Ads

Share this page:

Htaccess Redirect generates the rules needed to move visitors between the www and non-www version of a domain. It is for Apache servers that use .htaccess files.

Why use .htaccess Redirect Generator

  • Standardise on one hostname after a site migration.
  • Fix duplicate versions of a site appearing in search results.
  • Set up a canonical redirect on shared Apache hosting.

Running .htaccess Redirect Generator step by step

  1. Enter the domain name without a path.
  2. Choose the redirect direction: www to non-www, or non-www to www.
  3. Click Get Your HtAccess Code and copy the rules into your .htaccess file.

Good to know before you start

Back up .htaccess before editing. A syntax error can take the whole site offline.

Practical notes

Redirect rules are order-sensitive. A broad rule placed before a specific one can catch traffic you meant to send elsewhere, so test the final configuration with several URL variants.

Mistakes worth avoiding

  • Creating a loop between www and HTTPS redirects.
  • Applying a rule without backing up the original .htaccess.

FAQ

Which direction should I choose?

Pick the version you want to keep. Most sites use the non-www apex domain, but the important thing is to redirect the other version consistently.

Will this work on Nginx?

No. Nginx does not read .htaccess. Use a server block redirect in the Nginx configuration instead.

Can I redirect to HTTPS as well?

Yes. Combine the hostname rule with an HTTPS redirect, but test carefully to avoid a loop between the two rules.