How avoid https problems in localhost

Since a solution to force browsers toward a secured connection (with https and not http) is using an .htaccess file in the root folder, you can avoid many problems with https in localhost with this code, which you can put into the .htaccess, before the last row:

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]{3}$

So your .htacces file should contain these rows

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^[^.]+.[^.]{3}$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

This way you will have, with the same file, in local an http connection, and in remore an https connection.

https in localhost

Ho provato in molti modi a creare dei certificati in local: sia Chrome sia Firefox li rifiutano.
Allora ho deciso di dire ai browser di accettare una eccezione alla sicurezza per quanto concerne localhost.
In linux però, con xampp, bisogna modificare anche il file /opt/lampp/etc/extra/httpd-ssl.conf indicandogli dove si trova localhost e poi riavviare il server, altrimenti dà un errore di permessi o di oggetto non trovato.