内容页如果自定义了存放目录,那么需要你自己单独写规则来匹配。
我一般将都是单独设置存放目录的,所以classid不能固定,所以需要根据id来匹配目录。
$r=$empire->fetch1("select classid,id from {$dbtbpre}ecms_news where id={$id} and newstime <= ". time() );
if(empty($r['id'])){
printerror('此信息不存在','',1,0,1);
}
$_GET['classid'] = $r['classid'];
下面是伪静态生成代码,放在网站根目录运行即可
<?php
define('EmpireCMSAdmin','1');
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//验证用户
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//ehash
$sql=$empire->query("select classname,classid,classpath from {$dbtbpre}enewsclass");
while($s=$empire->fetch($sql)){
$wjt.= "rewrite ^([^\.]*)/{$s[classpath]}/$ \$1/e/action/ListInfo/index.php?classid={$s[classid]} last;\n";
$wjt2.= "rewrite ^([^\.]*)/{$s[classpath]}/(.+?)\.html$ \$1/e/action/ShowInfo.php?classid={$s[classid]}&id=\$2 last;\n";
}
?>
<pre><?=$wjt?><?=$wjt2?></pre>
10.14
新增加apache的规则
<?php
define('EmpireCMSAdmin','1');
require("e/class/connect.php");
require("e/class/db_sql.php");
require("e/class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//验证用户
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//ehash
$sql=$empire->query("select classname,classid,classpath from {$dbtbpre}enewsclass");
while($s=$empire->fetch($sql)){
$wjt.= "rewrite ^([^\.]*)/{$s[classpath]}/$ \$1/e/action/ListInfo/index.php?classid={$s[classid]} last;\n";
$wjt2.= "rewrite ^([^\.]*)/{$s[classpath]}/(.+?)\.html$ \$1/e/action/ShowInfo.php?classid={$s[classid]}&id=\$2 last;\n";
$ap_wjt.= "RewriteRule ^{$s[classpath]}/$ e/action/ListInfo/?classid={$s[classid]}&page=0 \n";
$ap_wjt2.= "RewriteRule ^{$s[classpath]}/(.+?)\.html$ e/action/ShowInfo.php?classid={$s[classid]}&id=\$1 last;\n";
}
?>
Nginx规则:
<pre>
<?=$wjt?>
<?=$wjt2?>
</pre>
Apache规则:
<pre>
RewriteEngine On
RewriteBase /
<?=$ap_wjt?>
<?=$ap_wjt2?>
</pre>