====== Web Pages ======
Having a unique URL ("canonicalization") for each webpage is important in improving your "Pagerank". Canonicalization is accomplished by redirecting non-standard webpages to a preferred ("standard") webpage. There are a number of ways to redirect a webpage, but 301 (HTTP/1.1 Status Code, "Moved Permanently") redirect is the search engine friendly method which passes the pagerank and search engine ranking status from old to a new page. Here is an examples of how 301 redirect can be implemented on LAMP (Linux/Apache/Mysql/PHP) environment.
===== PHP Redirect =====
===== Apache .htaccess: non-www to www subdomain redirect =====
1. Make sure your httpd.conf file has the "Directory" directive with the "AllowOverride All" setting.
AllowOverride All
2. Enable Mod-Rewrite Module
Your apache configuration should have the mod-rewrite module enabled, which is the default. You can verify this by perusing httpd.conf file for the following line:
LoadModule rewrite_module modules/mod_rewrite.so
3. Create a .htaccess file in the document root directory of your website with the following content.
RewriteEngine On
RewriteCond %{http_host} ^example.com [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]
Just replace the "example.com" with the domain name you're trying to redirect.
You can permanently redirect non-www URL to the www URL with 301 redirect. For apache web server, you can create a .htaccess file on your document root folder with the following content:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]