VPS侦探论坛

标题: LNMP环境下,论坛程序MyBB的伪静态rewrite开启方法 [打印本页]

作者: ccloving    时间: 2011-2-19 14:04
标题: LNMP环境下,论坛程序MyBB的伪静态rewrite开启方法
经过反复试验,这个方法可行,当然不只是Mybb论坛程序,其他伪静态的开启方法也类似,Mybb是小型的论坛程序,支持静态需要在后台里将'Server and Optimization options' 里面 'Enable search engine friendly URLs?' 设置成 'Enabled'。
然后更改htacess.txt改为.htaccess
最后新建.conf文件放到/usr/local/nginx/conf/ 目录下,如:
MyBB.conf
Mybb.conf内容如下:

location / {
    # ...your location settings are here...

    rewrite ^/MyBB/forum-([0-9]+)\.html$ /MyBB/forumdisplay.php?fid=$1;
    rewrite ^/MyBB/forum-([0-9]+)-page-([0-9]+)\.html$ /MyBB/forumdisplay.php?fid=$1&page=$2;
    rewrite ^/MyBB/thread-([0-9]+)\.html$ /MyBB/showthread.php?tid=$1;
    rewrite ^/MyBB/thread-([0-9]+)-page-([0-9]+)\.html$ /MyBB/showthread.php?tid=$1&page=$2;
    rewrite ^/MyBB/thread-([0-9]+)-lastpost\.html$ /MyBB/showthread.php?tid=$1&action=lastpost;
    rewrite ^/MyBB/thread-([0-9]+)-nextnewest\.html$ /MyBB/showthread.php?tid=$1&action=nextnewest;
    rewrite ^/MyBB/thread-([0-9]+)-nextoldest\.html$ /MyBB/showthread.php?tid=$1&action=nextoldest;
    rewrite ^/MyBB/thread-([0-9]+)-newpost\.html$ /MyBB/showthread.php?tid=$1&action=newpost;
    rewrite ^/MyBB/thread-([0-9]+)-post-([0-9]+)\.html$ /MyBB/showthread.php?tid=$1&pid=$2;

    rewrite ^/MyBB/post-([0-9]+)\.html$ /MyBB/showthread.php?pid=$1;

    rewrite ^/MyBB/announcement-([0-9]+)\.html$ /MyBB/announcements.php?aid=$1;

    rewrite ^/MyBB/user-([0-9]+)\.html$ /MyBB/member.php?action=profile&uid=$1;

    rewrite ^/MyBB/calendar-([0-9]+)\.html$ /MyBB/calendar.php?calendar=$1;
    rewrite ^/MyBB/calendar-([0-9]+)-year-([0-9]+)\.html$ /MyBB/calendar.php?action=yearview&calendar=$1&year=$2;
    rewrite ^/MyBB/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ /MyBB/calendar.php?calendar=$1&year=$2&month=$3;
    rewrite ^/MyBB/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ /MyBB/calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4;
    rewrite ^/MyBB/calendar-([0-9]+)-week-(n?[0-9]+)\.html$ /MyBB/calendar.php?action=weekview&calendar=$1&week=$2;

    rewrite ^/MyBB/event-([0-9]+)\.html$ /MyBB/calendar.php?action=event&eid=$1;
}


注意:如果论坛在网站根目录就把/MYBB/改成 “/” 如果在forum目录就改为 /forum/.
在usr/local/nginx/conf/vhost里找到虚拟主机的配置文件,打开后将:
include none.conf;或者include other.conf;
改为:
include MyBB.conf;
然后SSH执行命令 /root/lnmp restart
重启后,MyBB就支持伪静态了!
原文链接:
http://www.yyserver.tk/html/space/LNMP/2011/0219/25.html

[ 本帖最后由 ccloving 于 2011-2-19 14:06 编辑 ]
作者: czfdzx    时间: 2011-2-19 18:42
为什么要开伪静态?现在的搜索引擎谁不认识动态网页?,伪静态,纯属多余.还消耗资源.
作者: ccloving    时间: 2011-2-23 23:35
对SEO有很大好处。谁用谁知道




欢迎光临 VPS侦探论坛 (https://bbs.lnmp.com/) Powered by Discuz! X3.4