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
- How HTTPS redirection works
- How to set up redirection on Webhosting
- Common Problems
- Frequently Asked Questions
Kdy tento návod použijete
- Přesměrování nastavené v administraci domény nefunguje, když návštěvník zadá adresu s HTTPS, nebo Chrome stránku otevře přes HTTPS (Přesměrování z administrace domény nefunguje přes HTTPS).
- Prohlížeč u adresy s HTTPS hlásí chybu, stránka nereaguje nebo má chybný certifikát (Redirection with HTTPS).
- Máte doménu jen pro přesměrování na jiný web a chcete, aby fungovala přes HTTP i HTTPS (Setting Up Redirection on Webhosting).
- Přesměrování po nastavení někomu funguje a jinému ne, například jen se zadaným www (Přesměrování funguje jen někomu).
- Zobrazuje se chyba TOO MANY REDIRECTS (TOO MANY REDIRECTS).
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:
- The domain you want to redirect is set as the name or Webhosting alias.
- The Webhosting directory structure uses rules for different alias websites (multihosting).
- The domain points in DNS to the hosting that redirects it. If you use WEDOS DNS, you can have it pointed automatically when you set up the alias; otherwise you must set up DNS manually. You can find the IP addresses of the services in the guides DNS – A and AAAA Records.
- On the given Webhosting, you use the default .htaccess file. If you do not, follow the chapter Non-Default .htaccess.
- If you want to redirect via HTTPS, also make sure that you have a Let’s Encrypt certificate activated on the Webhosting for the redirected domain, as described in the guide Webhosting – Manual HTTPS Setup.
Then follow these steps:
- Log in to the Webhosting FTP as described in the guide FTP – Login.
- Go to the folder www/domains.
- Create a new directory named after the domain you want to redirect.
- In this directory, create a new file named .htaccess (including the dot at the beginning).
- 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.

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 error
- Přesměrování z administrace domény nefunguje přes HTTPS
- Přesměrování funguje jen někomu
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.