在phpcms v9首页实现如下分页:域名/page/$page
1、在apache中设置伪静态如下:
<VirtualHost *:80>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule /page/([0-9]+) /index.php?m=content&c=index&a=init&page=$1
</IfModule>
<Directory d:/www/php>
      Options FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
   DocumentRoot “d:/www/php”
   DirectoryIndex page/1
   ServerName www.php114.com
</VirtualHost>
2、在phpcms\modules\content\index.php文件中,找到init()方法:$SEO = seo($siteid);在这一句上面加入$page = intval($_GET[‘page’]);
3、修改phpcms\libs\functions\global.func.php中pageurl($urlrule, $page, $array = array())函数:
原方法如下:
function pageurl($urlrule, $page, $array = array()) {
if(strpos($urlrule, ‘~’)) {
$urlrules = explode(‘~’, $urlrule);
$urlrule = $page < 2 ? $urlrules[0] : $urlrules[1];
}
$findme = array(‘{$page}’);
$replaceme = array($page);
if (is_array($array)) foreach ($array as $k=>$v) {
$findme[] = ‘{$’.$k.’}’;
$replaceme[] = $v;
}
$url = str_replace($findme, $replaceme, $urlrule);
$url = str_replace(array(‘http://’,’//’,’~’), array(‘~’,’/’,’http://’), $url);
return $url;
}
修改后为:
function pageurl($urlrule, $page, $array = array()) {
if($page == 0){$page= 1;}
if(strpos($urlrule, ‘~’)) {
$urlrules = explode(‘~’, $urlrule);
$urlrule = $page < 2 ? $urlrules[0] : $urlrules[1];
}
/*$find = “index.php?m=content&c=create_html&a=public_index&pc_hash=”;
$rel_url =  strstr($urlrule,$find);
if(!empty($rel_url)){
$urlrule = ‘page/{$page}’;
}*/
$finds = “/page\/[1-9]+/”;
preg_match($finds,$urlrule,$matches);
if(!empty($matches)){
$newurl = explode(“?”, $urlrule);
$urlrule = substr_replace($newurl[0],'{$page}’,26);
}
$finds1 = “/\?page=\{[$]{1}page\}/”;
preg_match($finds1,$urlrule,$matches01);
if(!empty($matches01)){
$newurls = str_replace(“?”, “”, $matches01[0]);
$urlrule =str_replace(“=”, “/”, $newurls);
}
$findme = array(‘{$page}’);
$replaceme = array($page);
if (is_array($array)) foreach ($array as $k=>$v) {
$findme[] = ‘{$’.$k.’}’;
$replaceme[] = $v;
}
$url = str_replace($findme, $replaceme, $urlrule);
$url = str_replace(array(‘http://’,’//’,’~’), array(‘~’,’/’,’http://’), $url);
return $url;
}