Godaddy等的windows主机安装Discuz!X1.5、X2、X3在URL网址出现子目录名的解决办法

Discuz的安装文件中依次打开source文件夹—class文件夹—class_core.php文件,查找到$_G[‘siteurl’] = htmlspecialchars字段和$_G[‘siteroot’] = substr字段,两个字段在相邻的上下两行,即:

$_G[‘siteurl’] = htmlspecialchars(‘http://’.$_SERVER[‘HTTP_HOST’].preg_replace(“/\/+(api)?\/*$/i”, ”, substr($_G[‘PHP_SELF’], 0, strrpos($_G[‘PHP_SELF’], ‘/’))).’/’);
$_G[‘siteroot’] = substr($_G[‘PHP_SELF’], 0, -strlen($_G[‘basefilename’]));

将上面的代码替换成(以子目录名为bbs为例,不是bbs的将下面代码中的/bbs/替换成/子目录名/):

$_G[‘siteurl’] = str_replace(“/bbs/”,””,htmlspecialchars(‘http://’.$_SERVER[‘HTTP_HOST’].preg_replace(“/\/+(api)?\/*$/i”, ”, substr($_G[‘PHP_SELF’], 0, strrpos($_G[‘PHP_SELF’], ‘/’))).’/’));
$_G[‘siteroot’] = str_replace(“/bbs/”,””,substr($_G[‘PHP_SELF’], 0, -strlen($_G[‘basefilename’])));

然后将class_core.php文件上传到网站相应的目录,问题就解决了。

One comment

Leave a Reply to 鉴风博客 Cancel Reply

Required fields are marked *. Your email address will not be published.