Reputation: 600
i want to access my website by ip and domain but i don't want google indexing ip. taking example of google, i can access google by both doamin https://www.google.com/
and ip http://202.166.193.159/
.
i tired 301 redirect in htaccess by doing like this
RewriteEngine On
RewriteCond %{HTTP_HOST} ^202\.166\.193\.159$
RewriteRule ^(.*)$ https://www.google.com/$1 [L,R=301]
this doesn't give me the solutions. I want to access by both but don't want indexing by ip
Thanks!
Upvotes: 1
Views: 77
Reputation: 18671
You can redirect for Googlebot with root .htaccess
:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^googlebot
# With your IP !
RewriteCond %{HTTP_HOST} ^202\.166\.193\.159$
# With your domain !
RewriteRule ^ https://www.google.com%{REQUEST_URI} [L,R=301,NE]
Upvotes: 1