PHPCMS V9默认的动态页面网址太长了,比如默认的栏目网址为:/index.php?m=content&c=index&a=lists&catid=9;
内容页面网址为:/index.php?m=content&c=index&a=show&catid=11&id=46
通过修改,我们可以用更加干净、简短的网址(/index.php/a/lists/catid/9/和/index.php/a/show/catid/11/id/46/index.html)来访问它们。
打开\phpcms\libs\functions\extention.func.php文件,在末尾的“?>”前面添加以下代码:global $_URLCFG;
$_URLCFG=array();
$_URLCFG['urlmode']=2;
$_URLCFG['urlsuffix']='index.html';
getQueryString();
/**
* 获得友好的URL访问
*
* @access public
* @return array
*/
function getQueryString(){
global $_URLCFG;
if($_URLCFG['urlmode']!=2) return $_GET;
$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
if(!$path){
$script_name=$_SERVER['SCRIPT_NAME'];//获取当前文件的路径
$path= $_SERVER['REQUEST_URI'];//获取完整的路径,包含"?"之后的字符串
//去除url包含的当前文件的路径信息
if($path && @strpos($path,$script_name,0)!==false)
{
if($path!=$script_name) $path=substr($path,strlen($script_name));
}else{
$script_name=str_replace(basename($script_name),'',$script_name);
if($path && @strpos($path,$script_name,0)!==false){
$path=substr($path,strlen($script_name));
}
}
//第一个字符是'/',则去掉
if($path[0]!='/'){
$path='/'.$path;
}
if(strpos($path,'/index.php')===0) $path=preg_replace('|^/index\\.php|','',$path);
//去除问号后面的查询字符串
if($path && false!==($pos=@strrpos($path,'?'))){
$path=substr($path,0,$pos);
}
}
$_SGETS = explode('/',substr($path,1));
$_SLEN = count($_SGETS);
$_SGET =& $_GET;
for($i=0;$i
if(!empty($_SGETS[$i]) && !empty($_SGETS[$i+1])) $_SGET[$_SGETS[$i]]=$_SGETS[$i+1];
}
$_SGET['m'] = !empty($_SGET['m']) && is_string($_SGET['m']) ? trim($_SGET['m']) : '';
$_SGET['c'] = !empty($_SGET['c']) && is_string($_SGET['c']) ? trim($_SGET['c']) : '';
$_SGET['a'] = !empty($_SGET['a']) && is_string($_SGET['a']) ? trim($_SGET['a']) : '';
return $_SGET;
}
进入后台-》扩展-》修改URL规则:
1、将内容模块原来默认的动态category URL规则修改为:/index.php/a/lists/catid/{$catid}/index.html|/index.php/a/lists/catid/{$catid}/page/{$page}/index.html
2、将内容模块原来默认的动态show URL规则修改为:index.php/a/show/catid/{$catid}/id/{$id}/index.html|index.php/a/show/catid/{$catid}/id/{$id}/page/{$page}/index.html
3、进入“内容”管理页面,分别更新栏目缓存和更新URL网址
软件大小:8.04MB
软件类别:国产软件 | CMS建站
软件语言:简体中文
运行环境:PHP/Mysql
软件授权:免费版
更新时间:2015-12-28 10:33:57