栏目 文章 标签 Rewrite规则 示例
程序后台配置如图 标签设置
如果您的配置跟图中有不同之处
下面规则请做相应该的修改
你要原封不动复制粘贴,造成访问不了。
那就好自为之吧,我只能帮你到这了
到于什么是Rewrite,APACHE/nginx怎么设置Rewrite 请自行google
注:最后设置完成 最好看下最终的网址路径是什么样子的
如果包含/html/test/index.html
/html/2016/12/12/123.html
可在
把/html/
换成/
APACHE版 IIS的跟APACHE差不多
RewriteEngine on
RewriteBase /
##标签
RewriteRule ^tag/(\w+)$ tag.php?tkey=$1 [L]
RewriteRule ^tag/(\w+)/index_(\d+).html$ tag.php?tkey=$1&page=$2 [L]
##文章
RewriteRule ^\w+/\d+/\d+/(\d+).html$ article.php?id=$1 [L]
RewriteRule ^\w+/\d+/\d+/(\d+)_(\d+).html$ article.php?id=$1&p=$2 [L]
##栏目
RewriteRule ^(\w+)/$ category.php?dir=$1 [L]
RewriteRule ^(\w+)/index.html$ category.php?dir=$1 [L]
RewriteRule ^(\w+)/index_(\d+).html$ category.php?dir=$1&page=$2 [L]
nginx版
##标签
rewrite "^/tag/(\w+)/$" /tag.php?tkey=$1 last;
rewrite "^/tag/(\w+)/index.html$" /tag.php?tkey=$1 last;
rewrite "^/tag/(\w+)/index_(\d+).html$" /tag.php?tkey=$1&page=$2 last;
##文章
rewrite "^/\w+/\d+/\d+/(\d+).html$" /article.php?id=$1 last;
rewrite "^/\w+/\d+/\d+/(\d+)_(\d+).html$" /article.php?id=$1&p=$2 last;
##栏目
rewrite "^/(\w+)/$" /category.php?dir=$1 last;
rewrite "^/(\w+)/index.html$" /category.php?dir=$1 last;
rewrite "^/(\w+)/index_(\d+).html$" /category.php?dir=$1&page=$2 last;