|
Edelman Technologies Add www to Domain Using .htaccessBy David Edelman on 03.08.07 Is your website accessible at example.com and www.example.com? If so, then you're not optimized for search engines! Think of every link your site receives as a vote. If you get five links to example.com and five links to www.example.com, you have two separate web pages with five votes. It would be much better if you could tell Google to use one of those pages and give it a ranking of ten. On an Apache server, you can using .htaccess and mod_rewrite. Simply place this .htaccess file in the root of your site and change example to your web address:
RewriteEngine on tells Apache's mod_rewrite module to review each address and check it against the rules that follow. RewriteCond tells mod_rewrite what pattern to look for. In this case, it's anything that starts with "example.com". The dollar sign tells mod_rewrite to store all information after that point for later use. RewriteRule tells mod_rewrite what to do with the pattern it matched above (everything after the dollar sign). In this case, it says make the url "http://www.example.com/" and then append everything after the first (and in this case only) dollar sign here. The R=301 part is important. This tells the search engine that the page has permanently moved from example.com to www.example.com and it should transfer all of the votes there. Without this directive, Google would assume it's just a temporary move. For More InformationApache's mod_rewrite DocumentatonAn .htaccess Overview |