网站升级HTTPS教程


当前第2页 返回上一页

 

server {
        listen       80;
        root /www/web/idedecms_com/public_html;
        server_name idedecms.com idedecms.com www.idedecms.com img.idedecms.mysitecdn.com;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/404.html;
        error_page  503 /errpage/503.html;
        location ~ \.php$ {
                proxy_pass http://127.0.0.1:88;
                include naproxy.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
                try_files $uri @apache;
        }
        location @apache {
                 proxy_pass http://127.0.0.1:88;
                 include naproxy.conf;
        }
return 301 https://www.$server_name$request_uri;
}
server {
listen 443 ssl;
        root /www/web/idedecms_com/public_html;
        server_name idedecms.com idedecms.com www.idedecms.com img.idedecms.mysitecdn.com;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/404.html;
        error_page  503 /errpage/503.html;
        location ~ \.php$ {
                proxy_pass http://127.0.0.1:88;
                include naproxy.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
                try_files $uri @apache;
        }
        location @apache {
                 proxy_pass http://127.0.0.1:88;
                 include naproxy.conf;
        }
ssl_certificate /www/ssl/idedecms_com/1_www.idedecms.com_bundle.crt;
ssl_certificate_key /www/ssl/idedecms_com/2_www.idedecms.com.key;
ssl_session_timeout 5m;
} 

三、修改链接

下一步,网页加载的 HTTP 资源,网站页面js,css,以及图片资源引用地址改为https。因为加密网页内如果有非加密的资源,浏览器是不会加载那些资源的。

<script src="http://foo.com/jquery.js"></script>
上面这行加载命令,有两种改法。
<!-- 改法一 -->
<script src="https://foo.com/jquery.js"></script>
<!-- 改法二 -->
<script src="//foo.com/jquery.js"></script>

其中,改法二会根据当前网页的协议,加载相同协议的外部资源,更灵活一些。
另外,如果页面头部用到了rel="canonical",也要改成HTTPS网址。

<link rel="canonical" href="https://foo.com/bar.html" />

这个不用我说了吧,网站开启https之后,页面上使用http调用的资源都会无法调用。你需要把http的资源全都改成https调用。记住,不能漏掉任何一个js引用或者图片如果有一个文件不是https引用的,则你的网站虽然可以正常https访问,但是地址栏的https标识不会完全变绿,360浏览器尤为明显。这代表你网站虽然启用了https但是没有做到完全的规范。被认定为不规范的https页面。

四、301重定向

下一步,修改 Web 服务器的配置文件,使用 301 重定向,将 HTTP 协议的访问导向 HTTPS 协议。

Nginx 的写法。

server {
  listen 80;
  server_name domain.com www.domain.com;
  return 301 https://domain.com$request_uri;
}

Apache 的写法(.htaccess文件)。

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

iis下可以参考这篇文章 http://1000zx.cn/article/109087.htm

使用cdn的朋友可以联系cdn给设置301重定向


标签:织梦DedeCMS

返回前面的内容

相关阅读 >>

js获取ueditor富文本编辑器中的图片地址

dedecms 栏目页面转换为单独页面

15条实用的预防dede织梦网站被挂马方法

织梦DedeCMS在实现中英文导航功能方法步骤

将百度编辑器(ueditor)整合到dedecms中的方法

织梦模板dedecms首页301重定向的代码教程

织梦DedeCMS整合添加ckplayer播放器支持flv,mp4等播放功能

dedecms安全设置 执行php脚本限制设置方法(iis6+iis7+apache+nginx)

织梦DedeCMS网站建设栏目自动添加nofollow的方法介绍

织梦DedeCMS文章简介摘要字数的设置方法

更多相关阅读请进入《织梦DedeCMS》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...