Monday, December 7, 2009

Redirect Webpages to Another Domain

SkyHi @ Monday, December 07, 2009
Redirect Webpages to Another Domain
Filed in: Web Development — September 22nd, 2004


In case you need to change an existing website to another domain name. You don’t wish to lost your visitors. You want to auto redirect visitors to new location. You want address like “” will lead visitor to “”, as well as ALL other URL.

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} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1 [R=301,L]

Done! Now all visitors to the path) will auto redirected to appending path).