There comes a time that you ‘need’ to migrate your website to another domain name. There maybe tons of ways to redirect websites but learning them might take forever. To save you from headache, below are some of the .htaccess redirects that will be handy for webmasters.
RedirectMatch
RewriteEngineOn RedirectMatch 301 ^.*$ http://www.newdomain.org/
This is useful if you are to redirect all incoming traffic from your old domain to your new domain. In this case whatever location I type as long as it is under the old domain, it will be automatically redirected to the new domain.
WWW-Redirection
A lot of internet users have been typing “www”-versions or non-”www” versions of domain names on their browsers everyday. When I say non-”www” version it is the domain name without the “www” in front:
- http://pinoytech.org
When I say “www” version, it is the version with the “www” in front:
- http://www.pinoysmartlife.com
But what is the point of all these and why am I telling you this? It’s because it has a lot of benefits. Here are some to name a few:
- It causes Page Rank to spread. A proper 301 redirection would cause all links and Page Rank to be pointed to the version you choose to use.
- Search engines might give penalization on your website because of duplicate contents. Why? It’s because search engines don’t know that the “www” version and the non-”www” version is one and the same (unless you declare it in Google’s Webmaster Tools).
WWW-Redirection has been used by webmasters for years now. The only requirement for what I would teach would be that your site is hosted on an Apache web server.
Forward!
- non-WWW to WWW
RewriteEngineOn RewriteCond %(HTTP_POST) ^pinoytech\.org RewriteRule ^(.*)$ http://www.pinoytech.org/$1 [R=301, L]
This is useful if you are going to redirect your domain from the non-”www” version to the “www” version. In this example, anyone who goes into http://webmasterforumph.com will be automatically redirected to http://www.webmasterforumph.com/.
- WWW to non-WWW
RewriteEngineOn RewriteCond %(HTTP_POST) ^www\.pinoytech\.org RewriteRule ^(.*)$ http://pinoytech.org/$1 [R=301, L]
This redirection is useful if you are to redirect from a “www” version to the non-”www” version of the domain name. In this example, anyone who goes into http://www.webmasterforumph.com will be automatically redirected to http://webmasterforumph.com/.
