/ / Ako vynútiť SSL na konkrétnom súbore example.org/index.html? - php, .htaccess, ssl

Ako vynútiť SSL na konkrétnom súbore example.org/index.html? - php, .htaccess, ssl

Mám webovú stránku založenú na php .... snažím sa používať ssl... ssl funguje dobre v mieste, problém je, že to nie je presmerovanie s https .... to len ukazujú http a snažím sa upravovať v súbore .htaccess, ale nefunguje to .... otvoril sa aj môj web s týmto formátom example.org/index.html s index.html

Snažím sa použiť, ale nefunguje

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

.htaccess code:

RewriteEngine On
RewriteBase /
#AuthUserFile /home/products/html/path/.htpasswd
#AuthGroupFile /dev/null
#AuthName "Private Area"
#AuthType Basic
#<Limit GET POST>
#require valid-user
#</Limit>

<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=31536000, Public"
</IfModule>
</FilesMatch>

Options -Indexes

RewriteCond  %{REQUEST_FILENAME}  !-f

RewriteRule ^(.+).html$ $1/?%{QUERY_STRING}

-------urls---------

RewriteRule ^index/$ path/index.php
RewriteRule ^index/([^/]+)/$ path/index.php?list=$1&%{QUERY_STRING}

odpovede:

0 pre odpoveď č. 1

Na presmerovanie môžete použiť PHP.

Túto funkciu používam na kontrolu, či je žiadosť HTTPS alebo nie:

function isHttps() {
return (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === "on") || $_SERVER["SERVER_PORT"] === 443;
}

A teraz skontrolujte, či žiadosť nie je HTTPS, a presmerujte:

if (!isHttps()) {
header("location: https://www.example/index.php");
}

0 pre odpoveď č. 2

Vynútiť presmerovanie na zabezpečenú stránku:

if ($_SERVER["SERVER_PORT"] != "443") {
header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}