Redirect from IP-Adress to FQDN

I would like to redirect the query in the browser “http://192.168.1.1” to the domain “https://opnsense.dummy.tld”. So that the browser recognizes the certificate correctly and does not always get an error message.

In the internet there is an example how to go over a .htaccess - file, but I can’t find the place where I should insert the file.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^192.168.1.1$
RewriteRule ^(.*)$ https://opnsense.dummy.tld/$1 [L,R=301]

How could it be solved with the HAProxy ?