网站如何实现https访问(2)

当在B主机上测试成功时,这个https就大致实现了。不过呢,一般都设置个强制跳转,也就是http直接跳到https上。

6.http重定向https(强制跳转) 在C主机上 vim /etc/httpd/conf/httpd.conf Redirect temp|permanent / https://www.ab.com 注: temp为临时跳转代号302,permanent为永久跳转代号301,二者二选一。 service httpd restart or systemctl restart httpd

实际上,在实际运行中不是用上面的方法来把http重定向为https的,而是采用HSTS。HSTS使http调整到https的过程中没有网络过程,减少请求次数,节约了网络资源,所以应用更为广泛。

7.HSTS实现http重定向https 在C主机上 vim /etc/httpd/conf/httpd.conf Header always set Strict-Transport-Security "max-age=15768000" RewriteEngine on RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301] service httpd restart or systemctl restart httpd

到此为止,上述就是整个实现https的过程,若有什么地方错误,欢迎广大朋友指出!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/c5c161d234a1a1aad3685255be0fd87d.html