当前位置: 首页 > IT网络 > 正文

Apache用.htaccess来实现强制https访问

我们可以用Apache的.htaccess来实现http强制跳转到https访问网站。
代码如下:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://cdn.uu126.cn/$1 [R,L]

如果是在子目录,可以用:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} subfolder
RewriteRule ^(.*)$ https://cdn.uu126.cn/blog [R,L]

您可能还会对这些文章感兴趣!

《Apache用.htaccess来实现强制https访问》等您坐沙发呢!

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

Gravatar

? razz sad evil ! smile oops grin eek shock ??? cool lol mad twisted roll wink idea arrow neutral cry mrgreen