Redirecting IP address to domain

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


Active Member

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

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. :)