• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 542
  • Last Modified:

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

0
ellandrd
Asked:
ellandrd
  • 2
  • 2
  • 2
  • +1
1 Solution
 
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
 
fosiul01Commented:
Ok so where are you putting this urles ?? in .httaccess file or in apache ??
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now