1

Discuz手机版修改默认主页

 2 years ago
source link: https://muyexi.im/discuzshou-ji-ban-xiu-gai-mo-ren-zhu-ye/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Aug 7, 2022 1 min read Discuz

Discuz手机版修改默认主页

打开Discuz! X3.4论坛手机版首页时,会自动跳转到论坛页(/forum.php?forumlist=1&mobile=2),而不是首页(/forum.php?mod=guide&view=new&mobile=2)。

打开管理中心-全局-域名设置-应用域名,手机域名确实是论坛页,尝试修改,始终报错:

请您填写合法的域名,常见错误为以 “http://”、“.”开头或者以“/”、“/index.php”、“.”结尾,或域名包含未转换为 Punycode 的国际化域名等

只好直接修改数据表pre_common_nav中“手机版”对应的字段,但这只修好了页面底部的“手机版”链接。

检索后发现控制页面跳转的代码在source/class/discuz/discuz_application.php文件中如下位置:

if(strpos($this->var['setting']['domain']['defaultindex'], CURSCRIPT) !== false && CURSCRIPT != 'forum' && !$_GET['mod']) {
    if($this->var['setting']['domain']['app']['mobile']) {
        $mobileurl = $this->var['scheme'].'://'.$this->var['setting']['domain']['app']['mobile'];
    } else {
        if($this->var['setting']['domain']['app']['forum']) {
            $mobileurl = $this->var['scheme'].'://'.$this->var['setting']['domain']['app']['forum'].'?mobile=yes';
        } else {
            $mobileurl = $this->var['siteurl'].'forum.php?mobile=yes';
        }
    }
    
    # Fix Default Mobile Homepage: https://codetreasures.com/blog/detail/3TxqyIpZ0v
    $mobileurl = "https://www.YOUR-DOMAIN.com/forum.php?mod=guide&view=new&mobile=2";
    
    if(!$this->var['setting']['mobile']['otherindex']){
        dheader("location:$mobileurl");
    }
}

直接修改此处的$mobileurl即可。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK