一、檢查服務(wù)器是否支持rewrite
例如本地開啟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" ,注意命名時要加上"",得到.htaccess文件,然后把以下代碼寫進去保存。
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ī)則。
要是想在本地測試,例如 127.0.0.1/my2400,因為不是根目錄訪問,所以把以上代碼改寫如下(多了個/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后臺設(shè)置分類欄目。
位置:內(nèi)容->管理欄目->添加欄目
注意設(shè)置第二選項卡,“生成HTML設(shè)置”
欄目頁URL規(guī)則:list-1-2-1.html
內(nèi)容頁URL規(guī)則:content-1-2-1.html
四、批量更新URL,完成偽靜態(tài)設(shè)置。
相關(guān)文章教程推薦:phpcms教程