bbPress nginx 静态化

最近开始接触到bbPress这个简洁清爽的论坛程序,比起discuz它可是舒服的很,没有一些多余的无用的垃圾功能,插件也很丰富(相对)。不过,他也一样继承了wordpress的蛋疼的模板的方法。 我们现在来看看如何将它静态化: 这里使用的bbPress是1.1版本,其他的版本可以类推。 我们了解到,bbPress在Apache中静态化设置是这样的: [sourcecode language="plain"] RewriteRule ^page/([0-9]+)/?$ /index.php?page=$1 [L,QSA] RewriteRule ^forum/([^/]+)/page/([0-9]+)/?$ /forum.php?id=$1&page=$2 [L,QSA] RewriteRule ^forum/([^/]+)/?$ /forum.php?id=$1 [L,QSA] RewriteRule ^forum/?$ / [R=302,L,QSA] RewriteRule ^topic/([^/]+)/page/([0-9]+)/?$ /topic.php?id=$1&page=$2 [L,QSA] RewriteRule ^topic/([^/]+)/?$ /topic.php?id=$1 [L,QSA] RewriteRule ^topic/?$ / [R=302,L,QSA] RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ /tags.php?tag=$1&page=$2 [L,QSA] RewriteRule ^tags/([^/]+)/?$ /tags.php?tag=$1 [L,QSA] RewriteRule ^tags/?$ /tags.php [L,QSA] RewriteRule ^profile/([^/]+)/page/([0-9]+)/?$ /profile.php?id=$1&page=$2 [L,QSA] RewriteRule ^profile/([^/]+)/([^/]+)/?$ /profile.php?id=$1&tab=$2 [L,QSA] RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ /profile.php?id=$1&tab=$2&page=$3 [L,QSA] RewriteRule ^profile/([^/]+)/?$ /profile.php?id=$1 [L,QSA] RewriteRule ^profile/?$ /profile.php [L,QSA] RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ /view.php?view=$1&page=$2 [L,QSA] RewriteRule ^view/([^/]+)/?$ /view.php?view=$1 [L,QSA] RewriteRule ^rss/?$ /rss.php [L,QSA] RewriteRule ^rss/topics/?$ /rss.php?topics=1 [L,QSA] RewriteRule ^rss/forum/([^/]+)/?$ /rss.php?forum=$1 [L,QSA] RewriteRule ^rss/forum/([^/]+)/topics/?$ /rss.php?forum=$1&topics=1 [L,QSA] RewriteRule ^rss/topic/([^/]+)/?$ /rss.php?topic=$1 [L,QSA] RewriteRule ^rss/tags/([^/]+)/?$ /rss.php?tag=$1 [L,QSA] RewriteRule ^rss/tags/([^/]+)/topics/?$ /rss.php?tag=$1&topics=1 [L,QSA] RewriteRule ^rss/profile/([^/]+)/?$ /rss.php?profile=$1 [L,QSA] RewriteRule ^rss/view/([^/]+)/?$ /rss.php?view=$1 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.*$ /index.php [L] [/sourcecode] 稍微修改一下,bbPress就可以在nginx中设置静态化链接了: [sourcecode language="plain"] rewrite ^/page/([0-9]+)/?$ /index.php?page=$1 last; rewrite ^/forum/([^/]+)/page/([0-9]+)/?$ /forum.php?id=$1&page=$2 last; rewrite ^/forum/([^/]+)/?$ /forum.php?id=$1 last; rewrite ^/forum/?$ /; rewrite ^/topic/([^/]+)/page/([0-9]+)/?$ /topic.php?id=$1&page=$2 last; rewrite ^/topic/([^/]+)/?$ /topic.php?id=$1 last; rewrite ^/topic/?$ /; rewrite ^/tags/([^/]+)/page/([0-9]+)/?$ /tags.php?tag=$1&page=$2 last; rewrite ^/tags/([^/]+)/?$ /tags.php?tag=$1 last; rewrite ^/tags/?$ /tags.php last; rewrite ^/profile/([^/]+)/page/([0-9]+)/?$ /profile.php?id=$1&page=$2 last; rewrite ^/profile/([^/]+)/([^/]+)/?$ /profile.php?id=$1&tab=$2 last; rewrite ^/profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ /profile.php?id=$1&tab=$2&page=$3 last; rewrite ^/profile/([^/]+)/?$ /profile.php?id=$1 last; rewrite ^/profile/?$ /profile.php last; rewrite ^/view/([^/]+)/page/([0-9]+)/?$ /view.php?view=$1&page=$2 last; rewrite ^/view/([^/]+)/?$ /view.php?view=$1 last; rewrite ^/rss/?$ /rss.php last; rewrite ^/rss/topics/?$ /rss.php?topics=1 last; rewrite ^/rss/forum/([^/]+)/?$ /rss.php?forum=$1 last; rewrite ^/rss/forum/([^/]+)/topics/?$ /rss.php?forum=$1&topics=1 last; rewrite ^/rss/topic/([^/]+)/?$ /rss.php?topic=$1 last; rewrite ^/rss/tags/([^/]+)/?$ /rss.php?tag=$1 last; rewrite ^/rss/tags/([^/]+)/topics/?$ /rss.php?tag=$1&topics=1 last; rewrite ^/rss/profile/([^/]+)/?$ /rss.php?profile=$1 last; rewrite ^/rss/view/([^/]+)/?$ /rss.php?view=$1 last; if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } [/sourcecode] 将代码放在对应的位置即可。 看,URL漂亮多了。