URL Redirects

A URL redirect allows you to direct web traffic from one URL to another.

Redirecting a domain with a URL redirect

The following procedure will redirect one or more domains to another domain. The steps assume a shell user named myuser, an application named myredirect, and a target domain of mydomain.com.

  1. Add to dashboard all of the domains which will be redirected. See Adding Domains for more information.

  2. Create a new PHP+Apache application via the dashboard. See Adding an Application for more information.

  3. Create a new site via the dashboard. See Adding Sites for more information.:

  4. When adding the site, use the "Add Domain to Site" button to add all of the domains and subdomains that you wish to redirect.

  5. When adding the site, use the "Add Application to Site" button add the myredirect application from step 2 using / as its path.

  6. Click the "Add Site" button to save the site.

  7. Create a file on the server at /home/myuser/apps/myredirect/.htaccess with the following contents to perform the redirect:

    RewriteEngine on
    RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L]
    

    Note that the redirect status code in the above example is "301" - this is the code used for a permanent redirect. If the redirect is temporary then use "302" like so:

    RewriteEngine on
    RewriteRule ^(.*)$ https://mydomain.com/$1 [R=302,L]
    

When those steps are complete, any traffic to the new site should be redirected to the same URI on https://mydomain.com.

Redirecing to HTTPS

You can redirect all of a site's traffic to HTTPS by enabling the "Encrypt All Traffic" option for the site:

Please see Adding Sites for more information.

Pulling it all together

Let's say you have the following domains...

  • domain1.com
  • www.domain1.com
  • domain2.com
  • www.domain2.com

... and you want them all to go to https://www.domain1.com. Here's how:

  1. Create the main website for www.domain1.com with the Let's Encrypt and Encrypt All Traffic options enabled.
  2. Using the domain redirection steps above, create a second website to serve the other three domains with the Let's Encrypt and Encrypt All Traffic options enabled.
  3. Use the following rewrite rules in the redirect app from step 2:
    RewriteEngine on
    RewriteRule ^(.*)$ https://www.domain1.com/$1 [R=301,L]