.htaccess 安全性_使用.htaccess强制安全(SSL)页面

.htaccess 安全性

Updated 11/3/2015: Added R=301 to ensure redirects are 301 permanent.

2015年1月3日更新:添加了R=301以确保重定向是301永久的。

A while back, I shared a method for forcing a secure page using PHP. What if you want to force SSL (https://) on an entire website though? You don't want to have to put force-SSL PHP code on every page, right? Well, the website's .htaccess file comes to the rescue.

不久前,我分享了一种使用PHP强制执行安全页面的方法 。 如果要在整个网站上强制使用SSL (https://) ,该怎么办? 您不想在每个页面上都放置强制SSL PHP代码,对吗? 嗯,该网站的.htaccess文件可助您一臂之力。

.htaccess代码 (The .htaccess Code)


RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]

Obviously, you'll want to change "domain.com" to your domain. Another short snippet of code that has a big impact on your website!

显然,您需要将“ domain.com”更改为您的域。 另一个简短的代码段会对您的网站产生重大影响!

翻译自: https://davidwalsh.name/force-secure-ssl-htaccess

.htaccess 安全性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值