让phpcms全站支持https修改教程

来源:芸宾网络  2024-02-26

程序修改部分
1、修改phpcms/modules/admin/site.php
大约45行和128行的正则
('/http://(.+)/$/i', $domain))
修改为:
('/(http|https)://(.+)/$/i', $domain))
2、修改phpcms/modules/admin/templates/setting.tpl.php大约18行中的正则
http://(.+)1$
修改为:
http[s]?://(.+)1$
3、修改phpcms/modules/admin/templates/site_add.tpl.php大约13行中的正则
http://(.+)/$
修改为:
http[s]?://(.+)/$
4、修改phpcms/modules/admin/templates/site_edit.tpl.php大约11行中的正则
http://(.+)/$
修改为:
http[s]?://(.+)/$
5、修改phpcms/modules/link/templates/link_add.tpl.php大约10行中的正则
^http://[A-Za-z0-9]+.[A-Za-z0-9]+[/=?%-&](2)$
修改为:
^http[s]?://[A-Za-z0-9]+.[A-Za-z0-9]+[/=?%-&](2)$
6、修改phpcms/modules/link/templates/link_edit.tpl.php大约11行中的正则
^http://[A-Za-z0-9]+.[A-Za-z0-9]+[/=?%-&](2)$
修改为:
^http[s]?://[A-Za-z0-9]+.[A-Za-z0-9]+[/=?%-&](2)$
7、修改phpcms/modules/link/index.php大约41行和51行中的正则
/http://(.*)/i
修改为:
/^http[s]?://(.*)/i
8、修改phpcmslibsfunctionsglobal.func.php
大约738行的正则
$url = str_replace(array('http://','//','~'), array('~','/','http://'), $url);
修改为
$url = str_replace(array('https://','//','~'), array('~','/','https://'), $url);
9、修改phpcmsmodulescontenttemplatescontent_list.tpl.php
大约97行
elseif(strpos($r['url'],'http://')!==false)
修改为
elseif(strpos($r['url'],'https://')!==false)
10、修改phpcmsmodulescontenttemplatescontent_page.tpl.php
大约28行
if(strpos($category['url'],'http://')===false)
修改为
if(strpos($category['url'],'http://')== =false && strpos($category['url'],'https://')===false)

接着修改后台设置->基本设置 对应的css、js、图片、附件的路径全改为https
还有后台设置-> 站点管理 里面的站点域名http改为https

如果你的网站是使用了https 但是url没有显示绿色的安全 则需要在head头部代码 加入

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

最后更新站点首页,内容页,栏目页。

最新文章
多一份咨询,总有益处
联系芸宾网络,直接与程序员对接,免费获得行业报价方案
咨询热线:18370053265
微信号:wangzhankaifa18

扫一扫程序员咨询

扫一扫官方公众号

签订合同安心保障

网站免费预设计,满意后再签合同,开发票。

合理的网站报价

程序员接单!无中介费用,纯开发费用,公开透明,中途绝无加价情况

10年网站开发经验

10年的网站开发经验,拥有丰富的网站源代码,快速解决客户网站需求

免费售后服务

常年微信售后,当天解决网站出现的各种运维问题,让你的网络营销无后顾之忧。