让phpcms全站支持https修改教程

[复制链接]
zzfsmsk 发表于 2023-9-20 02:53:03|来自:北京丰台 | 显示全部楼层 |阅读模式
程序修改部分
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?://(.+)1$
3、修改phpcms/modules/admin/templates/site_add.tpl.php大约13行中的正则
http://(.+)/$
修改为:
http?://(.+)/$
4、修改phpcms/modules/admin/templates/site_edit.tpl.php大约11行中的正则
http://(.+)/$
修改为:
http?://(.+)/$
5、修改phpcms/modules/link/templates/link_add.tpl.php大约10行中的正则
^http://[A-Za-z0-9]+.[A-Za-z0-9]+[/=?%-&](2)$
修改为:
^http?://[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?://[A-Za-z0-9]+.[A-Za-z0-9]+[/=?%-&](2)$
7、修改phpcms/modules/link/index.php大约41行和51行中的正则
/http://(.*)/i
修改为:
/^http?://(.*)/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=&#34;Content-Security-Policy&#34; content=&#34;upgrade-insecure-requests&#34; />
最后更新站点首页,内容页,栏目页。
全部回复0 显示全部楼层
暂无回复,精彩从你开始!

快速回帖

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则