redirecting http://-----to only http://www---

louisp2500

Regular Member
Joined
Feb 24, 2011
Messages
378
Reaction score
58
Can someone help me how to redirect my site to only show up with http://www and NOT without www?

My site is just a simple HTML site, no wordpress or joomla or anything else, just HTML

thanks in advance :)
 
Hi,

1.First of all create a file in notepad named htaccess.txt on your desktop.

2.add the following code in this file -
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

3.Upload it to the root of your website

4.rename htaccess.txt to .htaccess

This should be ok.
 
i have just gone from windows to mac, what can i use as notepad on a mac?
 
i have just done it, but it didnt seem to work, i have contactet my serverprovider
 
Thanks, but i cant seem to get it working
 
You can try to create htaccess file via bbedit on Mac. Add the following code in it, save it as .txt file and upload it in the default site directory.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
 
Try this:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase / 
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
 
If 301 redirection seems that difficult, you can use rel=canonical in your header section
below all the meta data in the header section, you can type
<link rel="canonical" href="http://www.____">.
This wont remove your http://________ page but it requests google to consider only the page with canonical tag.
 
Back
Top