Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect IP address to domain name

Tags:

redirect

Not sure how it happened, but Google has indexed my site both by IP address and domain name and in some search in Google I see my site like 121.12.12.123/tech/tech.php.

Please let me know how can I redirect it to my domain?

121.12.12.123    redirect to   www.mydomain.com
121.12.12.123/*  redirect to   www.mydomain.com/*
like image 457
Kaveh Avatar asked Jul 30 '11 03:07

Kaveh


1 Answers

If your site is running on a apache webserver, you could use mod_rewrite and put something like this in your .htaccess:

RewriteCond %{HTTP_HOST} ^121\.12\.12\.123
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
like image 155
Gryphius Avatar answered Oct 14 '22 13:10

Gryphius