Redirecting IP address to domain

#1
Is there a special way to redirect the site ip address to the domain? I've tried adding to the rewrite section:
Code:
RewriteCond %{HTTP_HOST} ^121\.121\.11\.121
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
Also tried using:
Code:
RewriteCond %{HTTP_HOST} !^www\.my-domain\.com$
RewriteRule ^(.*)$ http://www.my-domain.com/$1 [R=301,L]
Which should just route all requests that does not start with www to the www, but none of these work.
 

lsmichael

Active Member
#2
Howdy,

There doesn't seem to be anything wrong with the rewrites off the bat. Turn rewrite logging to level 9 and see what errors you get. (It's in the rewrite tab as Log Level.)

m
 
#3
Managed to get it working. I didn't notice my rewrite rule was (.*), using ^(.*)$ worked, although I didn't think it would make a difference in this case. The weird thing is on one install using (.*) works... I'm just happy it works now. :)
 
Top