How to Redirect Site Using a .htaccess File? – Change Domain Names Without Lose SEO

There may come a time in your website’s life when you wish to change domain names. Whether due to a rebrand or a better URL becoming available, changing domain names is a big decision that requires a great deal of planning.

301 Redirect Everything!

Setting up a 301 redirect will not only send the user to the correct page, but it will also tell search engines that the page has permanently been moved and transfer the link credit to the new page.

You can create what is called a “wild card” redirect in your .htaccess file that will transfer everything on a domain-name level. Essentially, this automatically adds a 301 redirect to all of your old domain URLs and pushes them to the new domain with the same URL.

It’s critical that you take your time and ensure everything is getting 301 redirected properly. This is very important for both traffic and search. You can use a 301 checker to make sure everything is being transferred properly.

How to Redirect Site Using a .htaccess File?

APPLIES TO: ALL SERVICE TYPES

  • Difficulty: Medium
  • Time Needed: 10
  • Tools Required: FTP, plain text editor

As a configuration file, .htaccess is very powerful. Even the slightest syntax error (like a missing space) can result in your content not displaying correctly or at all.

Since .htaccess is a hidden system file, please make sure your FTP client is configured to show hidden files. This is usually an option in the program’s preferences/options.

1. Create an empty text file using a text editor such as notepad, and save it as htaccess.txt.

NOTE:

The reason you should save the file as htaccess.txt is that many operating systems and FTP applications are unable to read or view .htaccess files by default. Once uploaded to the server you can rename the file to .htaccess.

2. Edit the contents of the file. Check the following examples:

301 (Permanent) Redirect: Point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the “mt-example.com” domain:

302 (Temporary) Redirect: Point an entire site to a different temporary URL. This is useful for SEO purposes when you have a temporary landing page and plan to switch back to your main landing page at a later date:

Redirect index.html to a specific subfolder:

Redirect an old file to a new file path:

Redirect to a specific index page:

3. Upload this file and re-name it to .htaccess.

NOTE:

  • If using a text editor, be sure to save the file as plain text.

More Powerful URL Changes with mod_rewrite

If you need to make complex changes to the way your URL displays, you should visit Using .htaccess rewrite rules. You can do things like add “www” to the beginning of your URL, redirect all requests to a subfolder but keep the rest of the URL, etc.

Looking for WordPress hosting?

While choosing a new web host, make sure you don’t make the same common mistakes that most beginners do. A few of my favorite web hosts are ASPHostPortal, HostForLIFE, UKWindowsHostASP.NET. I recently reviewed ASPHostPortal and in my opinion, they’re the best shared host out there out of the large lot of hosts I’ve tested. If you’re curious as to why I never had to switch to another host since 2014, give my ASPHostPortal review a read.

A great place to look for a new web host is WebHostingTalk. Their members are very helpful and new members get proper guidance on choosing a web host.

How to Redirect Site Using a .htaccess File? – Change Domain Names Without Lose SEO
Rate this post