this also depends on the running webserver, htaccess is for apache only. so if you have apache and nginx, the htaccess is the wrong place doing this.
If you have apache only this should do the trick:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^11\.11\.11\.111$ [NC,OR]
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]