- Your cart is currently empty.
How to Redirect Your Website to WWW or HTTPS
Sometimes we want our website (or a specific place on the website) to redirect to a different web address. Redirecting to the “www” subdomain is also very common. This means that we type http://vasadomena.si in the address bar and it redirects us to the subdomain http://www.vasadomena.si.
Regarding redirection to HTTPS: the following instructions only describe how to redirect a domain to HTTPS, but most websites need to be ADAPTED to work on HTTPS before this can be done, otherwise the website will not display correctly. How you make your website HTTPS-enabled depends on how your website is designed. If it is a WordPress website, you can check the instructions in the post: How to migrate a WordPress site to HTTPS?
How do I set up a redirect?
There are several ways to edit a redirect, but all redirects are written to the .htaccess file located in the main folder of the website. As this is a hidden file, it is also necessary to enable the display of hidden files and folders. You can check how to do this here.
The .htaccess file also affects the performance of other web pages if they are located in a subfolder of the main page. If you don’t want the top .htaccess file to affect the website in the subfolder, add RewriteEngine On to the beginning of the .htaccess file in the subfolder. If the .htaccess file does not exist, create one. Websites such as WordPress, Joomla, etc. already have a default .htaccess file, so you don’t need to worry about this.
a) Edit redirects using Redirects in cPanel
Most redirects can be edited in the cPanel control panel -> Domains section -> Redirects icon. When you change a redirect, it will be written to the .htaccess file.
Editing redirects in the cPanel control panel
- Type: you can choose between permanent (301) and temporary (302) redirection. We usually use a permanent redirect (a temporary redirect tells search engines to index both links, which is not recommended if it is a redirect that will be permanent or if it is a redirect to another domain).
- http://(www.)?: to redirect, first select the domain you want to redirect from the drop-down list on the left. If you only want to redirect to specific subfolders, then enter the name of that folder (or several subfolders) in the box on the right, for example: folder1 or folder1/folder2.
- Redirects to: enter the web address to which the web page should be redirected.
- www.Redirection: select whether you want only the domain without “www” (for example http://vasadomena.si), only the domain with “www” (for example http://www.vasadomena.si) or both to be redirected. By default, the redirection is set to apply to both the domain with and without “www”.
When you have finished with the above settings, click the“Add” button.
Below, in the Current Redirects section, you can check which redirects you have already set up. Of course, you can also check all redirects in the .htaccess file.
If a redirect is not working, check that it is written at the beginning of the .htaccess file, which is located in the main folder of this website. If it is added at the end, move it to the beginning and check again that it works.
b) Edit redirects using the .htaccess file
You can also edit redirects directly using the .htaccess file.
You can write different redirects and rules in the .htaccess file as you wish. You can also find ways to edit different redirects on the web. For example, some of the more commonly used redirects are (NOTE: instead of vasadomena.si, enter your actual domain):
1. WWW-only redirect for any domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
2. Redirect to HTTPS only for any domain
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NO]
3. Redirect to HTTPS WWW for any domain
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
4. Redirect to HTTPS non-WWW for any domain
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
5. Redirect to HTTPS only for a specific domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^vasadomena\.si [OR]
RewriteCond %{HTTP_HOST} ^www.vasadomena\.si [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
6. Redirect to HTTPS WWW for a specific domain
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?vasadomena\.si$
RewriteRule (.*) https://www.vasadomena.si/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^vasadomena\.si$
RewriteRule (.*) https://www.vasadomena.si/$1 [R=301,L]
7. Redirect to HTTPS non-WWW for a specific domain
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?vasadomena\.si$
RewriteRule (.*) https://vasadomena.si/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www.vasadomena\.si$
RewriteRule (.*) https://vasadomena.si/$1 [R=301,L]
We are also always available by phone or email for any further questions.


COMMENT THE POST
Your comment has been successfully submitted
The comment will be visible on the page when our moderators approve it.