By default, when you install an SSL certificate, visits to the unsecured version of your website (http://www.tudominio.com) are not automatically redirected to the secure version (https://www.tudominio.com).
Below, we show you several ways to configure automatic redirection from HTTP (port 80) to HTTPS (port 443).
If your server uses Apache (which is usually the case), this is the quickest and easiest method:
data/web directory and locate the .htaccess file. If it doesn’t exist, create it.RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Note: Some CMS platforms, such as WordPress, automatically modify
.htaccess. In these cases, configure the redirect from your CMS dashboard or use another method described in this guide.
If you have root access to your server:
apache2ctl -S*:80 is a NameVirtualHost
port 80 namevhost swpanel.com (/etc/apache2/sites-enabled/swpanel.com.conf:2)
alias www.swpanel.com
nano):nano /etc/apache2/sites-enabled/swpanel.com.conf
</VirtualHost>:<VirtualHost *:80>
ServerName swpanel.com
ServerAlias www.swpanel.com
DocumentRoot "/var/www/swpanel.com/datos/web"
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</VirtualHost>
Ctrl + X, then Y and Enter).apache2ctl -t
The following should appear: Syntax OK.
/etc/init.d/apache2 graceful/etc/init.d/apache2 graceful
Access your domain at http:// to verify that it automatically redirects to https://.
If your server uses Nginx and you have root access:
cd /etc/nginx/sites-enabled
ls
nano):nano /etc/nginx/sites-enabled/swpanel.com.conf
server {
listen 80;
root "/var/www/swpanel.com/datos/web";
index index.html index.php;
server_name swpanel.com www.swpanel.com;
return 301 https://$server_name$request_uri;
}
Ctrl + X, then Y and Enter).nginx -t
It should look something like:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
/etc/init.d/nginx reload
Go to your domain at http:// to verify that it automatically redirects to https://.