1、確認空間支持僞靜態,有些空間商的空間是需要手動開啓僞靜態功能的。
2、後臺--系統--系統設置--僞靜態參數設置,設置好僞靜態規則。
3、新建 .htaccess 文件,放在網站根目錄下。
.htaccess文件中寫入如下規則:(注意規則文件中的規則要與後臺設置的一致)
# 將 RewriteEngine 模式打開
RewriteEngine On
#信息內容頁:showinfo-[!--classid--]-[!--id--]-[!--page--].html
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^showinfo-(.+?)-(.+?)-(.+?)\.html$ /e/action/ShowInfo.php?classid=$1&id=$2&page=$3
#信息列表:listinfo-[!--classid--]-[!--page--].html
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^listinfo-(.+?)-(.+?)\.html$ /e/action/ListInfo/index.php?classid=$1&page=$2
#標題分類列表頁:infotype-[!--ttid--]-[!--page--].html
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^infotype-(.+?)-(.+?)\.html$ /e/action/InfoType/index.php?ttid=$1&page=$2
#TAGS信息列表頁:tags-[!--tagname--]-[!--page--].html
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^tags-(.+?)-(.+?)\.html$ /e/tags/index.php?tagname=$1&page=$2
應用:
RewriteEngine on //啓動rewrite引擎
RewriteRule ^([^-]*)-([^-]*)-([^-]*)-([^-]*)-([^-]*).html$ /e/action/ListInfo.php?classid=106,107&ph=1&orderby=$1&&zhuangtai=$2&shouzhong=$3&diyu=$4&ticai=$5
RewriteRule ^([^-]*)-([^-]*)-([^-]*)$ /e/action/ListInfo.php?classid=106,107&line=25&tempid=17&ph=1&andor=and&orderby=onclick&myorder=0&totalnum=$1&page=$2&ticai=$3
#http://hao123manhua.92demo.com/424-5-冒險
# ErrorDocument 404 /index.html