Redirect IP to domain
snippet in htaccess

Redirect IP to domain

user1268

RewriteEngine On
RewriteCond %{HTTP_HOST} ^11\.11\.11\.111$ [NC,OR]
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

Redirect IP to domain

user3011

RewriteEngine On
RewriteCond %{HTTP_HOST} ^11\.11\.11\.111$ [NC,OR]
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

Redirect IP to domain

user2616

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^111\.111\.111\.111
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]

Redirect IP to domain

user6212

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^111\.111\.111\.111
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]