How to use .htaccess for Redirection




Recently, when I had a domain change, I needed something in order to transfer all of my traffic from the old domain to the new one. So I used .htaccess for the redirection.

You can also use this, by typing the following in your .htaccess:

RewriteEngine OnRewriteCond %{HTTP_HOST} ^.*oldwebsite\.com$ [NC]

RewriteRule ^(.*)$ http://www.preferredwebsite.net/$1 [R=301,L]

Replace oldwebsite\.com with the current website and replace http://www.preferredwebsite.net with the new website URL where you want to redirect the traffic to.

If you want to know what did I used for my old domain, then see below:

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

Was this post helpful? Follow us on Twitter (@SizzledCore) or become our Facebook fan for all the latest updates!