Tag Archives: plesk

Redirect domain and its subdomains in Plesk

Sometimes a domain alias in Plesk doesn’t do exactly what you want. If you domain is handled by Google Apps / G-Suite or points to external services an alias won’t alias properly.

These instructions assume domain.com is setup correctly. With the below setup other-domain.com will redirect to domain.com and subdomain.other-domain.com will redirect to subdomain.domain.com. It will also handle folders so subdomain.other-domain.com/test will redirect to subdomain.domain.com/test

  • Add a domain (other-domain.com)
  • Go to Apache & nginx Settings
  • Add the following to Additional directives for HTTP(S)
    RewriteEngine on
    RewriteCond %{HTTP_HOST} (.*) [NC]
    RewriteRule ^(.*)$ https://domain.com$1 [L,R=301,NC]
    
  • Add a * subdomain (*.other-domain.com)
  • Go to Apache & nginx Settings for *.other-domain.com
  • Add the following to Additional directives for HTTP(S)
    RewriteEngine on
    RewriteCond %{HTTP_HOST} (.*)(other-domain\.com) [NC]
    RewriteRule ^(.*)$ http://%1.domain.com$1 [L,R=301,NC]
    

The above settings could also go in .htaccess. If you aren’t using Apache use the htaccess to nginx plugin.