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. Under "Application Routing Info" add the myredirect application from step 2 using / as the route URI path.

  5. Under "Domain Info" add all of the domains and subdomains that you wish to redirect.

  6. Save the site.

  7. Create a file /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]