一、檢查服務(wù)器是否支持rewrite
例如本地開(kāi)啟rewrite方法如下:
Apache 配置文件 httpd.conf
1、
LoadModule rewrite_module modules/mod_rewrite.so
把這句的“#”注釋掉。
2、
AllowOverride none
改為
AllowOverride all
3、重啟apache服務(wù)器。
二、準(zhǔn)備.htaccess文件(如何建立. htaccess )
若是windows,可以使用記事本,保存選擇另存為,".htaccess" ,注意命名時(shí)要加上"",得到.htaccess文件,然后把以下代碼寫(xiě)進(jìn)去保存。
RewriteEngine On RewriteRule ^(.*)content-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/index.php?m=content&c=index&a=show&catid=$2&id= $3&page=$4 RewriteRule ^(.*)show-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/index.php?m=content&c=index&a=show&catid=$2&id= $3&page=$4 RewriteRule ^(.*)list-([0-9]+)-([0-9]+).html$ $1/index.php?m=content&c=index&a=lists&catid=$2&page=$3
以上的是.htaccess規(guī)則。
要是想在本地測(cè)試,例如 127.0.0.1/my2400,因?yàn)椴皇歉夸浽L問(wèn),所以把以上代碼改寫(xiě)如下(多了個(gè)/my2400):
RewriteEngine On RewriteRule ^(.*)content-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/my2400/index.php?m=content&c=index&a=show&catid= $2&id= $3&page=$4 RewriteRule ^(.*)show-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/my2400/index.php?m=content&c=index&a=show&catid=$2&id= $3&page=$4 RewriteRule ^(.*)list-([0-9]+)-([0-9]+).html$ $1/my2400/index.php?m=content&c=index&a=lists&catid=$2&page=$3
三、PHPCMS V9后臺(tái)設(shè)置分類欄目。
位置:內(nèi)容->管理欄目->添加欄目
注意設(shè)置第二選項(xiàng)卡,“生成HTML設(shè)置”
欄目頁(yè)URL規(guī)則:list-1-2-1.html
內(nèi)容頁(yè)URL規(guī)則:content-1-2-1.html
四、批量更新URL,完成偽靜態(tài)設(shè)置。
相關(guān)文章教程推薦:phpcms教程