Webhosting – Redirect Domain via HTTPS

  Web Hosting

This article addresses domain redirection using a .htaccess file on Webhosting. If you don’t have Webhosting and HTTP redirection is enough, follow the instructions in the Domains – Basic Redirection article.

In this article, you will learn:

HTTPS Domain Redirection

The following procedure uses the ability to generate an SSL certificate for a domain or subdomain on a Webhosting service or its alias.

The redirect itself is handled by the .htaccess file, which redirects HTTPS requests to the specified address.

Domain Redirection via Webhosting

Before you set up domain redirection on Webhosting, make sure that:

  • You have the domain you want to redirect set as a Webhosting name or alias.
  • The domain in DNS points to the hosting that redirects it. If you have WEDOS DNS, you can have it routed automatically when setting up the alias, otherwise you have to set the DNS manually. You can find out the IP addresses of the services according to the instructions DNS – Type A Records and DNS – Type AAAA Record. Doména v DNS směřuje na hosting, který ji přesměrovává. Máte-li DNS WEDOS, můžete ji nechat nasměrovat automaticky při nastavování aliasu, v opačném případě musíte DNS nastavit ručně. IP adresy služeb zjistíte podle návodů DNS – Záznamy typu A a DNS – Záznamy typu AAAA.
  • You are using the default .htaccess file. If not, follow the chapter Non-default .htaccess.
  • If you want to redirect via HTTPS, also make sure that you have an activated Let’s Encrypt certificate for the redirected domain according to the instructions Webhosting – Manual HTTPS Stup.

Then follow these steps:

  1. Log into FTP according to the guide Webhosting – FTP Access.
  2. Navigate to the www/domains folder.
  3. Create a new folder with the name of the domain you want to redirect.
  4. In this directory, create a new file with the name .htaccess (including the .).
  5. Paste this code into the new .htaccess file:

RewriteEngine On
RewriteRule (.*) https://newdomain.tld/ [R=301,L]

Replace newdomain.tld with the domain you want to redirect to, and save.

WEDOS Sample redirection via .htaccess file
Sample redirection via .htaccess file

Redirecting via Webhosting should work immediately after saving the .htaccess file, as long as the conditions are met. If it doesn’t work, perform the test in an incognito window or clear your browser cache.

Non-default .htaccess

This procedure may cause errors on the original Webhosting domain.

If you are not using the default WEDOS .htaccess in the www folder, add this code to the beginning of the modified .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?redirecteddomain\.tld$
RewriteRule (.*) https://newdomain.tld/$1 [R=301,L]

Edit the second line of code to match the domain you are redirecting (the alias). Place the \ (backslash) character before each period of the domain name. 

Edit the third line of the code to match the new address where you the domain should redirect.

Common issues

Common redirect issues include:

TOO MANY REDIRECTS

Issue: TOO MANY REDIRECTS error is displayed instead of the redirected website.

Cause: A loop occurred while redirecting. Most often you cause it by directing the domain to itself.

Solution: Make sure the address you are redirecting to is different than the original domain.

If the problem persists, try expanding the code to:

RewriteEngine On 
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://newdomain.tld/$1 [R=301,L]

FAQ

Question: What if I have no Webhosting service?
Answer: If you do not need redirection via HTTPS, you can still set up redirection from the domain according to the instructions Domains – Basic Redirection.

Děkujeme za zpětnou vazbu!