PDA

View Full Version : redirect IP address


lesmith
12-14-2007, 06:40 PM
Hello Chaps

Hope you can advise on a htaccess redirect.

We have develop a site which has been running from the IP address as the nameservers had not been updated to recently.

Google some how has managed to find the site and has now indexed it via the IP address.

How can I write a htaccess so that if someone hits the site via an IP address they would be redirect to the domain name.

I have tried this.

RewriteCond %{HTTP_HOST} !^123\.123\.123\.123 [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

But it has not worked.

Can you advise.

Thank you in advanced if you can help.

lesmith
12-14-2007, 07:18 PM
Dont worry.

Got it in the end.

If you wanted to know this is what I done and worked.

RewriteCond %{HTTP_HOST} ^123\.123\.123\.123
RewriteRule ^(.*)$ http://www.domain.com [R=permanent,L]