PHPCMS V9 如何启用伪静态
最近在研究CMS时候,首先是使用DEDECMS,后来又转到了PHPCMS,感觉后者架构更加合理,而前者主要是模板众多,故使用者多一些,不过我都是需要自己写模板,那就无所谓了。玩各种CMS我喜欢首先看看是否支持伪静态,因为我认为作为建站的初期,访问量一般不会很大,故使用动态页面就足够了,不需要全部网页都静态化,在不断的修改中还得不断的生成查看效果,故还是直接动态方便些,而一般CMS都具备伪静态来实现动态页的静态地址。当然,如果你是做很大的站点,可以不采纳我的这个建议。
在安装完最新版的PHPCMS V9版后,默认是不启用伪静态的,你需要经过一些设置才能实现。
.htaccess文件
首先第一点,你需要在网站根目录下放置一个“.htaccess”文件,来标明其“Rewrite”规则。这个文件实际在最新版的V9版的readme目录下有,默认跟上传目录分开的,刚才说了,PHPCMS默认是不开启伪静态的。所以,你只需要将其上传到你的根目录即可。当然你也可以自己编写,其内容如下:
[*]RewriteEngine on
[*]RewriteRule ^content-(+)-(+)-(+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
[*]RewriteRule ^show-(+)-(+)-(+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
[*]RewriteRule ^list-(+)-(+).html index.php?m=content&c=index&a=lists&catid=$1&page=$2
复制代码
栏目管理设置不生成Html
第二步,你需要在你的后台栏目管理里面,对你的各个栏目设置为不生成Html,默认是生成的,请注意。
同时,你还需要选择栏目页和内容页的URL规则如上图所示的规则类型。
一切设置完毕后,更新你的缓存,就完工了!
官网下载的的.htaccess 伪静态文件:
RewriteEngine on
RewriteRule ^content-(+)-(+)-(+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
RewriteRule ^show-(+)-(+)-(+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
RewriteRule ^list-(+)-(+).html index.php?m=content&c=index&a=lists&catid=$1&page=$2
互换为IIS7下的web.config文件:
<rewrite>
<rules>
<rule name="Imported Rule 1">
<match url="^content-(+)-(+)-(+).html" ignoreCase="false" />
<action type="Rewrite" url="index.php?m=content&c=index&a=show&catid={R:1}&id={R:2}&page={R:3}" appendQueryString="false" />
</rule>
<rule name="Imported Rule 2">
<match url="^show-(+)-(+)-(+).html" ignoreCase="false" />
<action type="Rewrite" url="index.php?m=content&c=index&a=show&catid={R:1}&id={R:2}&page={R:3}" appendQueryString="false" />
</rule>
<rule name="Imported Rule 3">
<match url="^list-(+)-(+).html" ignoreCase="false" />
<action type="Rewrite" url="index.php?m=content&c=index&a=lists&catid={R:1}&page={R:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
页:
[1]