Reputation: 2650
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/*
Upvotes: 12
Views: 38188
Reputation: 349
Here is the full htaccess for laravel to redirect from IP to Domain
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^5\.129\.317\.421$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
Upvotes: 0
Reputation: 78866
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]
Upvotes: 24