Apache下设置伪静态:
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} ^(.*)$
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