PHP.ph

29 Dec, 2007

WWW to Non-WWW, htaccess File, 301 Redirect

Posted by: php In: Apache

http://php.ph and http://www.php.ph are considered as different websites by search engines. This causes a potential for duplicate content problem. To solve this, you should make your domain accessible via one-way, either www or non-www version.

To redirect all traffic from http://php.ph to http://www.php.ph (substitute php.ph with your own domain name), edit your .htaccess file and add the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.php\.ph
RewriteRule (.*) http://www.php.ph/$1 [R=301,L]

Or if you prefer the non-www version, redirect all traffic from http://www.php.ph to http://php.ph (substitute php.ph with your own domain name), edit your .htaccess file and add the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.php\.ph
RewriteRule (.*) http://php.ph/$1 [R=301,L]

Tags:

No Responses to "WWW to Non-WWW, htaccess File, 301 Redirect"

Comment Form

About PHP.ph

Linux Apache MySQL PHP