Plesk

How to redirect IP address to domain name URL on Plesk for Linux server?

Question

How to redirect IP address to domain name URL on Plesk for Linux server?

Answer

Note: Replace example.com and 203.0.113.2 with the actual domain name and IP address. If you do not have administrative access to Plesk server, contact your hosting provider.

  1. Log in to Plesk
  2. Specify the domain example.com in the field Default site in the menu Tools & Settings > IP Addresses > 203.0.113.2:
  3. Add the following directive to the field Additional nginx directives in Domains > example.com > Apache & nginx settings and click OK or Apply at the bottom of the page:

    if ($host ~ '203.0.113.2'){
    rewrite ^/(.*)$ https://example.com/$1 permanent;
    }