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
Add to dashboard all of the domains which will be redirected. See Adding Domains for more information.
Create a new PHP+Apache application via the dashboard. See Adding an Application for more information.
Create a new site via the dashboard. See Adding Sites for more information.:
Under "Application Routing Info" add the
myredirectapplication from step 2 using
/as the route URI path.
Under "Domain Info" add all of the domains and subdomains that you wish to redirect.
Save the site.
Create a file
/home/myuser/apps/myredirect/.htaccesswith 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
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...
... and you want them all to go to https://www.domain1.com. Here's how:
- Create the main website for www.domain1.com with the Let's Encrypt and Encrypt All Traffic options enabled.
- 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.
- Use the following rewrite rules in the redirect app from step 2:
RewriteEngine on RewriteRule ^(.*)$ https://www.domain1.com/$1 [R=301,L]