Use this simple tool to generate .htaccess code to permanently, 301 redirect one domain to another.
Redirect old domain to new domain
Redirect to www
Redirect old directory to new directory
Redirect old URL to new URL
How it Works
The code generated is used to create SEO friendly permanent redirects.
Your website needs to be running on an Apache server with htaccess support enabled for these apache redirects to work. Please contact your hosting company in case the redirect code listed here does not work for you.
Refer to the 301 redirect tutorial for other methods on how to redirect a webpage.
301 Redirects and SEO
Since they are permanent redirects (not temporary for maintenance, etc.) 301 redirects pass between 90-99% of link juice (ranking power) to the redirected page.
There are a number of reasons that you may need to direct one domain to another. Perhaps you redesigned your site and have a new domain. Maybe you have unused domains for your brand that you would like to start using.
Regardless, in most cases, the 301 redirect is the best method for implementing redirects on a website if you are at all concerned about preserving the SEO value of the original domain.
How Do .htaccess 301 Redirects Work?
When you redirect an old domain to a new one, something needs to tell the web server for your old site to direct the traffic to a different location. One way to do this is with a simple text file with the extension .htaccess. (There isn’t a file name, just an extension.)
Note* This .htaccess method of redirection works ONLY on Linux servers with the Apache Mod-Rewrite moduled enabled.
Then, when users or search engines visit your website, the .htaccess file will direct them to the correct location.
Since it is a permanent redirect, the search engines will eventually replace the old domain with the new domain.
How to Create 301 Redirects with .htaccess
Step 1: Download or Create a New .htaccess File
Wait! You may already have an .htaccess file! Since .htaccess files are a simple way to communicate with your web server, they are used for a lot more than just 301 redirects.
Many website and content management tools, like WordPress, use .htaccess in order to work.
Before you create a new .htaccess file, we recommend that you check to see if your site already has one.
If you have one, great! Download the existing file, add the snippet of code from the domain redirect tool, save it, and upload it to your site.
If you do NOT have one, create a new file in a simple text editor, and save it as .htaccess (No file name, just the extension.)
Step 2: Generate the 301 redirect code
Use our .htaccess 301 Redirect Tool to generate the code for your redirect, and then copy and paste it into your .htaccess file.
Step 3: Upload Your .htaccess File
NOTE: If you already had an .htaccess file, be sure to download the existing file to a backup directory…Just in case. 😉
.htaccess files affect the directory they are in as well as any directories within that directory. So, in order to redirect an entire site, you need to place your .htaccess in the main web directory for your site. (Normally, this is the same directory as your index file/home page.)