开发过小程序案例的猿友一定知道的,今天就不讲https证书的申请,配置。回头会详细的讲一下https证书的申请以及配置,这次简单的分享一下如何使用.htaccess配置http强制跳转https
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<script type="text/javascript">
var url = window.location.href;
if (url.indexOf("https") < 0) {
url = url.replace("http:", "https:");
window.location.replace(url);
}
</script>
if ($_SERVER["HTTPS"] <> "on"){
$xredir="https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
header("Location: ".$xredir);
}
RewriteEngine on
RewriteBase /yourfolder
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
rewrite ^(.*)$ https://$host$1 permanent;
本站主要用于日常笔记的记录和生活日志。本站不保证所有内容信息可靠!(大多数文章属于搬运!)如有版权问题,请联系我立即删除:“abcdsjx@126.com”。
QQ: 1164453243
邮箱: abcdsjx@126.com