3

Quick Tips: Redirecting Website To A New Domain With Htaccess

Monie on September 24th, 2010 in Tutorials
redirect

Learn how to redirect your old website domain to your brand new domain simply with Htaccess.

You have purchased a new domain name, planning to get rid of your old domain name. So, what do you do next?

Before We Start?

Before changing your website old domain name into your brand newly purchased domain name, there is a few issue that you need to keep in mind, and the most important one are the 404 error.

You don’t want your visitors to get frustrated with getting a lot of 404 error message. It will somehow give a negative impression to your website and again, you really don’t want to do that!

Let’s Get Started With Our .htaccess File

If your web server is using Apache HTTP Server then you can use the powerful mod_rewrite module to do the task. It required only few lines of code.

Create a “.htaccess” file in your oldDomain’s web root folder(example: /public_html/) then enter the following codes in the file.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldDomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.oldDomain.com$
RewriteRule ^(.*)$ http://www.newDomain.com/$1 [R=301,L]

Done! Now all your visitors will be redirected from oldDomain.com(regardless the path) to newDomain.com

Happy redirecting…

3 Responses so far.

  1. Superb blog post, I have book marked this internet site so ideally I’ll see much more on this subject in the foreseeable future!

  2. Thank you, I have recently been searching for information about this topic for ages and yours is the best I have discovered so far.

  3. Monie says:

    Should you have any better way, please do share with me here.

Leave a Reply