Guides and tutorials

Hundreds of tutorials and step by step guides carefully written by our support team.

Redirect from www to non-www or the other way round via .htaccess

In this manual we will explain how to redirect your domain without www to a specific URL or to the same one with www, you only have to apply this change in the .htaccess file.

To do this, you can do it in two ways:

First option ⇾ Connect via FTP to the "/data/web/" directory and edit the ".htaccess" file.

Second option ⇾ In your SW Panel, you have a File Manager with which you can manage and administer the directories and files of your Web. You can guide you with the following manual

The ".htaccess" file is hidden. If you don't see it, you should enable the option to view hidden files in your FTP client. You may also need to create it. ⚠️

Next, add the lines of code we specified:

REDIRECT DOMAIN WITH NO 'WWW'

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.midominio.com [NC] RewriteCond %{HTTP_HOST} ^www.midominio.com [NC]
RewriteRule ^(.*)$ http://midominio.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^http://midominio.com/ [NC]

REDIRECT DOMAIN WITH 'WWW'

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com [NC] **RewriteRule
RewriteRule ^(.*)$ http://www.midominio.com/$1 [L,R=301]

REDIRECT DOMAIN INDISTINCTLY WITH 'WWW' or WITHOUT 'WWW' - HTTPS

This example can be given in the case you have an SSL certificate installed on a www.dominio.com and you would like to redirect all domains, both www and non-www domains, to https://www.dominio.com.

RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80 **RewriteRule
RewriteRule ^(.*)$ https://www.midominio.com/$1 [R,L]

More than 2000 m² of own facilities and Data Centers in Spain
Your privacy is important for us
We use our own cookies for the proper functioning of the site. In addition, third-party cookies are used for analytical purposes only. This information is not associated with any person so that personal identifying data is not stored, but is only information that is collected to identify the session, with the aim of facilitating the analysis of the website. You can change your preferences at any time by entering this website again. For more information about our cookie policy you can visit our Cookies. You can press the "Accept and close" button to give us your consent or you can access more detailed information and manage cookies.
More than 2000 m² of own facilities and Data Centers in Spain
Your privacy is important for us
We use our own cookies for the proper functioning of the site. In addition, third-party cookies are used for analytical purposes only. This information is not associated with any person so that personal identifying data is not stored, but is only information that is collected to identify the session, with the aim of facilitating the analysis of the website. You can change your preferences at any time by entering this website again. For more information about our cookie policy you can visit our Cookies. You can press the "Accept and close" button to give us your consent or you can access more detailed information and manage cookies.