Htaccess Redirect Generator


1. Select redirect type





2. Enter your domain name


Do not include www. Domain name only - e.g. yourdomain.com

3. Get your code


4. Copy the code to your .htaccess file



About Htaccess Redirect Generator

Htaccess Redirect Generator: Redirect WWW to Non-WWW or Non-WWW to WWW

Choose the type of redirect, enter your domain name, and click Get .htaccess Code. The tool creates the code that you can copy into your .htaccess file to send visitors to the version of your website that you prefer.

Why Redirect WWW and Non-WWW?

A website can often be opened at both www.example.com and example.com. Search engines treat these as two separate addresses. If both load without a redirect, your links and signals can be split between them. Google says that either version is fine, as long as you pick one and redirect the other to it with a permanent (301) redirect.

How to Use the Tool

  1. Select redirect type: choose "www to non-www" or "non-www to www".
  2. Enter your domain name: type the domain without www, for example yourdomain.com.
  3. Get your code: click Get .htaccess Code.
  4. Copy the code into your .htaccess file.

Before You Edit Your .htaccess File

  • Make a backup copy of the file first.
  • The .htaccess file is in the root folder of your website, usually public_html. It is a hidden file, so turn on "Show Hidden Files" in your file manager.
  • A mistake in this file can cause a 500 error on your whole site. If that happens, restore your backup.
  • This works on Apache and compatible servers such as LiteSpeed. It does not work on Nginx.
  • If your hosting panel or a plugin already forces www or HTTPS, check that you do not add a second, conflicting redirect.

After You Add the Code

Open the other version of your address in a browser to check that it redirects, and use our www Redirect Checker to confirm the result.

Frequently Asked Questions

Which is better, www or non-www?

Neither is better for search engines. Choose one and use it everywhere.

Does this tool create other redirects?

No. It creates only www and non-www redirects.

Is this tool free?

Yes, it is free to use.