Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For Apache, you can use <a href="http://httpd.apache.org/docs/2.2/mod/mod_ssl.html" rel="noreferrer"><code>mod_ssl</code></a> to force SSL with the <a href="http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslrequiressl" rel="noreferrer"><code>SSLRequireSSL Directive</code></a>:</p> <blockquote> <p>This directive forbids access unless HTTP over SSL (i.e. HTTPS) is enabled for the current connection. This is very handy inside the SSL-enabled virtual host or directories for defending against configuration errors that expose stuff that should be protected. When this directive is present all requests are denied which are not using SSL.</p> </blockquote> <p>This will not do a redirect to https though. To redirect, try the following with <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" rel="noreferrer"><code>mod_rewrite</code></a> in your .htaccess file</p> <pre><code>RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </code></pre> <p>or any of the various approaches given at</p> <ul> <li><a href="http://www.askapache.com/htaccess/http-https-rewriterule-redirect.html" rel="noreferrer">http://www.askapache.com/htaccess/http-https-rewriterule-redirect.html</a></li> </ul> <p>You can also solve this from within PHP in case your provider has disabled .htaccess (which is unlikely since you asked for it, but anyway)</p> <pre><code>if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') { if(!headers_sent()) { header("Status: 301 Moved Permanently"); header(sprintf( 'Location: https://%s%s', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'] )); exit(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload