Dont want to use the old fashioned www anymore? Want to make sure your users use the www? Want to make sure that search engines (or anywhere for that matter) end up at one or the other? Takes about 2 minutes to do either one of those.
Firstly, I'll go into it a little more. You have your domain name at
http://www.yoursite.com. The whole "www" this is very 90s and is slowly disapearing.
When a user types in or follows a link to
www.yoursite.com, why not have it redirect to
http://yoursite.com. It's better to have one or the other for search engines also, as they see the two addresses as different pages, and therefore effects the amount of people linking to your pages.
This method can be used for the opposite also. Here is how to quickly set one or the other..
Step 1
For this step you must be the owner of the site's host. Go to the index folder via ftp/telnet and there should be a file called ".htaccess". If you dont have one there, create one (chmod it to 644 if you create a new one)
Step 2
Edit the file in a plain text editor.
Do one of these two depending on what you want to achieve.
Enter this code if you wish to redirect the http:// to
http://www.
Quote:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=permanent]
|
Enter this code if you want to redirect the
http://www. to http://
Quote:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mydomain\.com
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=permanent]
|
Please note that the codes are case sensitive, and that you will obviously need to change mydomain.com to your actual domain name.
Source:
http://www.beginnerwebmaster.com/bw-...irect-the-www/