Redirect A Website with mod_rewrite

.htacess is very useful when you want to manage your website. It can be used to define the value that you want, block certain IPs, etc.

To redirect a website, you do not need to hard code from every single of your page, but you may use the .htaccess rewrite to get it done.

To redirect a domain name to www such as mickgenie.com to www.mickgenie.com

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

To redirect mickgenie.com and www.mickgenie.com to www.mickgenie.com

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

Published by

Mick Genie

Mick Genie is the founder of MickGenie.com and working at ExaBytes Network Sdn Bhd and WPWebHost web host company. He is expertise in Windows and Linux environment especially web hosting related information, tips and trick as well as the IT Information.