Loading... 本人用Discuz!X系列做站也有五年之久了,从X3.1再到如今的X3.4,各种问题修修补补~各种插件模板什么的,最后发现还是简简单单的最好 <div class="tip inlineBlock success"> 用户反馈访问手机版首页的时候总是提示“您访问的页面无手机页面,是否进一步访问电脑版?”的问题,当时找了很久也没有发现问题在哪,在网上很久终于找到了个修改代码的方式解决了,以下是当时修改的代码,仅对DZX3.0到3.3有效,最新的3.4已经合并此修改 </div> 打开source/function/function_core.php 搜索 ```php $mobiletplfile = ‘./template/default/’.$mobiletplfile; ``` 替换为 ```php $mobiletplfile = ‘./template/default/’.$file.’.htm’; ``` <div class="tip inlineBlock warning"> 后来发现有些用户即便是做了此修改,或者更新到了最新版,也同样会出现这个问题,经过多次实验才找到问题根源 </div> **不能设置非DZ内置的导航作为首页,即便是该页面存在手机版,也会出现这样的问题**![后台设置](/usr/uploads/2019/11/3552511814.png) PS:此DZ为二开版,不对外公开 设置类型为“自定义”的导航作为首页就会出现这样的问题 貌似和source/class/discuz/discuz_application.php里的以下代码有关(此处已合并https://gitee.com/ComsenzDiscuz/DiscuzX/commit/c004bbeed4d04a27516c6daa0e22bf4d656cc32c) ```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'; } } if(!$this->var['setting']['mobile']['otherindex']){ dheader("location:$mobileurl"); } } ``` 后面的更新貌似解决了这个问题,需要在后台————全局————手机版访问设置 开启以下功能 ![后台设置](/usr/uploads/2019/11/1489571836.png) 配合首页域名和默认域名设置为同一个,完美解决访问DZ手机版还会跳转到forum.php?mobile=yes或者其他URL的问题,直接就是http(s)://域名/ 不会再跳转到http(s)://域名/forum.php?mobile=yes 的地方 Last modification:November 6, 2024 © Reprint prohibited Support Appreciate the author AliPayWeChat Like If you think my article is useful to you, please feel free to appreciate