phpcmsv9 修改协议为https后分页无法正常显示的解决方法

本文详细介绍了如何将PHPCMSv9网站从HTTP迁移到HTTPS,包括修改核心函数、更新正则表达式匹配规则等关键步骤,确保网站在HTTPS环境下稳定运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

修改 phpcms\libs\functions\global.func.php

搜索function pageurl

替换原来的代码

$url = str_replace(array('http://','//','~'), array('~','/','http://'), $url);

//ASMITA修改
if(substr($url,0,5)=="https"){
	$url = str_replace(array('https://','//','~'), array('~','/','https://'), $url);
}
else{
	$url = str_replace(array('http://','//','~'), array('~','/','http://'), $url);
}

--------------------------以下为如何配置phpcms v9到https-----------------------------

我只复制了代码修改部分,其他没贴,需要的可以自己去看

原文:http://bbs.phpcms.cn/thread-936379-1-1.html

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:\/\/(.+)[^/]$

修改为
http[s]?:\/\/(.+)[^/]$

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]+[\/=\?%\-&]*([^<>])*$

修改为
^http[s]?:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&]*([^<>])*$

6.修改phpcms/modules/link/templates/link_edit.tpl.php
大约11行中的正则
^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&]*([^<>])*$

修改为
^http[s]?:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&]*([^<>])*$

7.修改phpcms/modules/link/index.php
大约41行和51行中的正则
/http:\/\/(.*)/i

修改为
/^http[s]?:\/\/(.*)/i

 

--------------另外一篇帖子中需要更正的地方----------------

原文:https://blog.youkuaiyun.com/a1079540945/article/details/79776704

找开 phpcms\modules\admin 下的 site.php文件,在大约128行修改如下:
if (!empty($domain) && !preg_match('/http:\/\/(.+)\/$/i', $domain)) {

修改为
if (!empty($domain) && !preg_match('/https:\/\/(.+)\/$/i', $domain)) {

此处最好修改为

if (!empty($domain) && !preg_match('/http:\/\/(.+)\/$|https:\/\/(.+)\/$/i', $domain)) {

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值