This simple trick allows you to redirect your site without the www (domain.com) to the www version (
www.domain.com). All you need to do is make a simple .htaccess edit.
Here's what you have to do:
1. Download your .htaccess file from your site's folder. If you have another site that is a subdomain or an add-on, go inside the folder. If it's in the root folder, edit the .htaccess in your root foder (public_html)
2. Open the file with your favourite text editor, i.e. Notepad.
3. Add this code at the top most area of the codes inside your .htaccess.
Quote:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule (.*) http://www.domain.com/$1 [R=Permanent]
|
Be sure to edit the "domain.com" to your site's domain name.
So it would look something like this:
Quote:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule (.*) http://www.domain.com/$1 [R=Permanent]
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.domain.com
AuthUserFile /home/accountname/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/accountname/public_html/_vti_pvt/service.grp
|
4. Upload your file and replace your old .htaccess and that's it.
5. Try surfing for your site domain.com without www and if the www shows up, it worked.
Enjoy! :sad:
BTW, if you think like this guy does,
Quote:
I understand what you are doing, but why would you want to?
The shorter the name the better. Less the www the better too.
What is the benefit of doing this?
|
Here's the answer.
Quote:
The Search Engine Crawlers interprete URLs like http://domain.com/ ( Non-www version) http://www.domain.com/ ( www version)
as different urls containing the same content. With recent Google drive to track pages containing duplicate content, there is always a possibility that your website may be penalised. So if you have the same problem ( just make a site: query in Google to see whether both www version as well as non-www version of your webpage is indexed therein), you need to resolve it at once.
-astahost.com
|