Knowledge Base›Webhosting›Redirecting a Domain with HTTPS

Webhosting – Redirecting a Domain with HTTPS

On this pageKdy tento návod použijeteRedirection with HTTPSSetting Up Redirection on WebhostingCommon ProblemsFrequently Asked Questions

This article covers domain redirection using the .htaccess file on Webhosting. If you do not have Webhosting, follow the guide in the article Domains – Basic Redirection.

V tomto článku se dozvíte:


Kdy tento návod použijete


Redirection with HTTPS

The following procedure uses the option to generate an SSL certificate for any domain or subdomain as part of the basic HTTPS setup on the Webhosting or its alias.

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

Jednoduché přesměrování nastavené v administraci domény s HTTPS nefunguje. Abyste přesměrovali i HTTPS, musí doména mířit na webhosting s vystaveným certifikátem a přesměrování nastavíte v souboru .htaccess podle tohoto článku.


Setting Up Redirection on Webhosting

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

Then follow these steps:

  1. Log in to the Webhosting FTP as described in the guide FTP – Login.
  2. Go to the folder www/domains.
  3. Create a new directory named after the domain you want to redirect.
  4. In this directory, create a new file named .htaccess (including the dot at the beginning).
  5. Paste the following code into the newly created .htaccess file:
RewriteEngine On
RewriteRule (.*) https://newdomain.tld/ [R=301,L]

Replace the text newdomain.tld in the code with the address you want to redirect the domain to. Then save the code.

Sample redirection setup using the .htaccess file
Sample redirection setup using the .htaccess file

If the conditions are met, redirection via Webhosting should work immediately after you save the .htaccess file. If it does not, test it in a private browser window.

Non-Default .htaccess

This procedure may cause errors on the website on the original Webhosting domain.

If in the folder www you do not use the default WEDOS .htaccess, add this code at the beginning of your modified .htaccess:

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

Druhý řádek kódu upravte na doménu, kterou přesměrujete. Před každou tečku doménového názvu umístěte znak \. 

Edit the third line of the code to the address you want to redirect the domain to.


Common Problems

Common redirection problems include:

TOO MANY REDIRECTS

Problem: Instead of the redirected website, the following error is displayed: TOO MANY REDIRECTS.

Cause: A loop occurred during redirection. It is most often caused by pointing a domain to itself.

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

If the problem persists, try extending the code to:

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

Přesměrování z administrace domény nefunguje přes HTTPS

Problem: Doména má v administraci nastavené přesměrování. Adresa s HTTP funguje, adresa s HTTPS nereaguje, nebo ji prohlížeč (zejména Chrome) otevře sám přes HTTPS a přesměrování se neprovede.

Cause: Přesměrovací server domény HTTPS nepodporuje. Doména mu navíc míří na přesměrovací server, ne na webhosting s certifikátem.

Solution: Nasměrujte doménu na webhosting (nebo ji na něm nastavte jako alias), vystavte pro ni Let’s Encrypt certifikát a přesměrování nastavte v souboru .htaccess podle kapitoly Setting Up Redirection on Webhosting. Bez webhostingu využijte HTTPS přesměrování přes WEDOS Protection.

Přesměrování funguje jen někomu

Problem: Přesměrování po nastavení někdo vidí správně, jinému se zobrazí nedostupná stránka (například jen u adresy bez www).

Cause: Prohlížeč nebo DNS má uloženou starou verzi stránky.

Solution: Načtěte stránku bez cache klávesovou zkratkou Ctrl+Shift+R, promažte cache prohlížeče, nebo web otevřete v anonymním okně či jiném prohlížeči. Cache návštěvníků neovlivníte, na přesměrovacím serveru domény nejde nastavit. Spolehlivější je přesměrovat přes .htaccess na webhostingu, kde můžete délku držení cache nastavit.


Frequently Asked Questions

What if I don’t have Webhosting?

You can use redirection from the domain as described in the guide Domains – Basic Redirection, where HTTPS can be provided by the WEDOS Protection Add-on Service.

How do I set up redirection on the WebSite 1.0 service?

On the WebSite service, you can set up redirection by inserting your own JavaScript in the page settings. However, this solution may not behave correctly in all browsers.

If you use a paid WebSite plan and want to use the service only for HTTPS redirection to another domain, request the setup via the form ⧉. Specify the WebSite service name and the target domain.

Po zřízení webhostingu přestalo fungovat přesměrování domény nastavené v administraci domény. Jak ji teď přesměruji?

Přes soubor .htaccess na webhostingu. Doména musí mířit na webhosting a mít vystavený Let’s Encrypt certifikát, postup je v kapitole Setting Up Redirection on Webhosting. Přesměrování pak funguje přes HTTP i HTTPS.

Co se stane, když pro přesměrovanou doménu nemám certifikát?

Přesměrování funguje jen přes HTTP, adresa s HTTPS skončí chybou. Přidejte doménu do certifikátu podle návodu Webhosting – Manual HTTPS Setup.

Was this article helpful?

Your feedback helps us improve our articles.

Your message goes to the documentation team, who do not reply to it. If you need help, contact us using the contact form. Do not include passwords or personal data.

Didn't find what you were looking for?

Ask other customers on the Help community website.