当前位置:Gxlcms >
数据库问题 >
SEO工具箱:PHP自动生成PHPCMS伪静态规则.htaccess
SEO工具箱:PHP自动生成PHPCMS伪静态规则.htaccess
时间:2021-07-01 10:21:17
帮助过:21人阅读
define(‘PHPCMS_PATH‘,
dirname(
__FILE__).
DIRECTORY_SEPARATOR);
include PHPCMS_PATH.‘/phpcms/base.php‘
;
//pc_base::creat_app();
$db_config = pc_base::load_config(‘database‘);
//读取配置文件
pc_base::load_sys_class(‘mysql‘, ‘‘, 0
);
pc_base::load_sys_class(‘param‘, ‘‘, 0
);
pc_base::load_model(‘content_model‘
);
$db=
new mysql();
$db->open(
$db_config[‘default‘
]);
$pre =
$db_config[‘default‘][‘tablepre‘];
//读取表前缀
$db->
connect();
$catprefix = ‘list‘
;
$catrule .= "<IfModule mod_rewrite.c>\n"
;
$catrule .= "RewriteEngine on\n"
;
$catdata =
$db->select(‘catid,catdir,parentid‘,"{
$pre}category","type=0"
);
foreach(
$catdata as $item){
$catdir =
$item[‘catdir‘
];
$catid =
$item[‘catid‘
];
$parentid =
$item[‘parentid‘] ?
$item[‘parentid‘] : ""
;
if(
trim(
$parentid)){
$parentdir =
$db->select(‘catdir‘,"{
$pre}category","catid={
$parentid}")[0][‘catdir‘
];
$catrule .= "RewriteRule ^{
$parentdir}/{
$catdir}/([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=show&catid={
$catid}&id=$2&page=$3\n"
;
}
$catrule .= "RewriteRule ^{
$catdir}/([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=show&catid={
$catid}&id=$2&page=$3\n"
;
}
$catrule .= "RewriteRule ^{
$catprefix}/([0-9]+)_([0-9]+).html index.php?m=content&c=index&a=lists&catid=$1&page=$2\n"
;
$catrule .= "</IfModule>\n"
;
file_put_contents(PHPCMS_PATH.‘/.htaccess‘,
$catrule);
/*RewriteEngine on
RewriteRule ^content-([0-9]+)-([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
RewriteRule ^show-([0-9]+)-([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
RewriteRule ^list-([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=lists&catid=$1&page=$2*/
SEO工具箱:PHP自动生成PHPCMS伪静态规则.htaccess
标签:col contents 技术 tac 描述 com rect zhang 友好