Redirect to SSL

2

I have added my SSL certificate to my website and it works well. What happens is that I must specifically search link , and that is not very effective. If I search for it as it is, without the https: //, I get the unsafe version of my website.

Is there no way, when someone directly searches for domain.com directly opens the secure page (with SSL)?

Thanks

    
asked by Pol Marín 30.09.2018 в 13:53
source

2 answers

1

You have several options:

1) Virtual Host: You can modify your virtual host file and indicate there that all requests on port 80 go to your website through port 443 :

<VirtualHost *:80>
    ServerName www.ejemplo.com
    Redirect / https://www.ejemplo.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName www.ejemplo.com
    # ... tu configuración SSL va aquí si tienes
</VirtualHost>

2) Index.php: If you have PHP installed on your server, you can use it in the root folder where your domain is pointing and place a file index .php so that redirects to your domain with port 443: :

<?php 
  header("Location: https://ejemplo.com");
  die();
?>

3) .htaccess: You can create a configuration file for Apache in the root folder where your domain is pointing to redirect you:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://ejemplo.com/$1 [R,L]
    
answered by 30.09.2018 / 14:18
source
1

In your .htaccess file you can use this code so that all the traffic on your site is redirected to Https:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
answered by 30.09.2018 в 14:14