This article deals with domain redirection using .htaccess file on Webhosting. If you do not have a Webhost, follow the instructions in the Domains - Basic Redirection article.
In this article you will read:
- How HTTPS redirection works
- How to set up redirection on web hosting
- Common problems
- Frequently Asked Questions
Redirection with HTTPS
The following procedure takes advantage of the ability to generate an SSL certificate for any domain or subdomain within the basic HTTPS setup of the web host or its alias.
The redirection itself is handled by the .htaccess file, which redirects the HTTPS request to the specified address.
Redirection settings on Webhosting
Before you set up a redirect on your Web Host, make sure that:
- You have set the domain you want to redirect as the name or alias of the Webhost.
- The Webhosting directory structure uses rules for different alias sites (multihosting).
- The domain in DNS points to the hosting that redirects it. If you have a WEDOS DNS, you can have it redirected automatically when you set the alias, otherwise you have to set the DNS manually. You can find out the IP addresses of the services by following the DNS instructions - A and AAAA records.
- You are using the default .htaccess file on your web host. If this is not the case, follow the chapter Other than the default .htaccess.
- If you want to redirect via HTTPS, make sure that you have Let's Encrypt certificate activated for the redirected domain on your webhost according to the Webhosting - Manual HTTPS Settings instructions.
Then follow these steps:
- Log in to the FTP web hosting by following the FTP - Login instructions.
- Go to the www/domains folder.
- Create a new directory with the name of the domain you want to redirect.
- In this directory, create a new file called .htaccess (including the period at the beginning).
- Insert the code into the newly created .htaccess file:
RewriteEngine On
RewriteRule(.*) https://novadomena.tld/ [R=301,L]
Rewrite the text novadomena.tld in the code to the address where you are redirecting the domain. Then save the code.

Redirection via Webhosting should work immediately after saving the .htaccess file. If it does not, run a test in an anonymous browser window.
Other than the default .htaccess
This procedure may cause site errors on the original Webhosting domain.
If you do not use the default WEDOS .htaccess in the www folder, insert the following code at the beginning of the modified .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?staradomena\.tld$
RewriteRule (.*) https://novadomena.tld/$1 [R=301,L]
Edit the second line of code to the domain you are redirecting. Place a \ before each dot of the domain name.
Edit the third line of code to the address where you are redirecting the domain.
Common problems
Common problems with redirection include:
TOO MANY REDIRECTS
Problem: Instead of the redirected site, I get a TOO MANY REDIRECTS error.
Cause: a loop occurred during redirection. Most often you cause it by pointing the domain to itself.
Solution: Make sure 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://novadomena.tld/$1 [R=301,L]
Frequently Asked Questions
What if I don't have Webhosting?
You can use domain redirection as described in Domains - Basic Redirection, where HTTPS can be provided by the WEDOS Protection add-on service.