Always redirect to www. not working

This is what im using but it doesnt redirect to http://www.antons-law.com/ if I enter http://antons-law.com/
RewriteEngine On
RewriteCond %{HTTP_HOST} ^antons-law\.com/$ [nc]
RewriteRule ^(\.*)$ http://www\.antons-law\.com/$1 [R=301,L]

Open in new window

LVL 16
ellandrdAsked:
Who is Participating?
 
Maciej SsysadminCommented:
Oh, and remove that ending / from RewriteCond (I didn't notice that earlier).
Corrected version:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^antons-law\.com$ [nc]
RewriteRule (.*) http://www.antons-law.com/$1 [R=301,L]

Open in new window

0
 
fosiul01Commented:
can you try with this ??

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^antons-law\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]

0
 
ellandrdAuthor Commented:
doesnt work
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
fosiul01Commented:
Ok so where are you putting this urles ?? in .httaccess file or in apache ??
0
 
Maciej SsysadminCommented:
(\.*) means 0 or more occurences of dot.
You want (.*) instead.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^antons-law\.com/$ [nc]
RewriteRule (.*) http://www.antons-law.com/$1 [R=301,L]

Open in new window

0
 
ellandrdAuthor Commented:
in a .htaccess file

ok i will remove the \.

0
 
caterham_wwwCommented:
Can you confirm that mod_rewrite works, e.g. by redirecting to google:
RewriteEngine on
RewriteRule ^ http://www.google.com [R,L]

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.