Its very important that the homepage of the website is accessible through one URL only. For example, a typical joomla site would be accessible by domainname.com, www.domainname.com, domainname.com/index.php and www.domainname.com/index.php. If you are using frontpage component on the homepage, you may have an additional URL for homepage. This way, the power of backlinks and google PR is distributed across several URLs. This can be easily taken care of by using the following code in .htaccess file.
For redirecting /index.php to www.domainname.com:
Options +FollowSymLinks
DirectoryIndex index.phpRewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.domainname.com/ [R=301,L]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
For redirecting domainname.com to www.domainname.com:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domainname.com [nc]
rewriterule ^(.*)$ http://www.domainname.com/$1 [r=301,nc]
Once you have done this, you can check the redirection using a fantastic redirect check tool I can across. This tool will provide all possible URLs for your homepage along with the response code. The response code of 200 which is an OK response should be returned by just one URL.
Comments
Post a Comment