一、检查服务器是否支持rewrite
1、
LoadModule rewrite_module modules/mod_rewrite.so登录后复制
把这句的“#”注释掉。
2、
AllowOverride none登录后复制
改为
AllowOverride all登录后复制
3、重启apache服务器。
二、准备.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规则。
要是想在本地测试,例如 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登录后复制