VPS侦探论坛

 找回密码
 注册
查看: 10182|回复: 2

LNMP环境下,论坛程序MyBB的伪静态rewrite开启方法

[复制链接]
发表于 2011-2-19 14:04:48 | 显示全部楼层 |阅读模式

经过反复试验,这个方法可行,当然不只是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 编辑 ]

评分

参与人数 1威望 +10 收起 理由
licess + 10

查看全部评分

美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-2-19 18:42:09 | 显示全部楼层


为什么要开伪静态?现在的搜索引擎谁不认识动态网页?,伪静态,纯属多余.还消耗资源.
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2011-2-23 23:35:26 | 显示全部楼层

对SEO有很大好处。谁用谁知道
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-19 09:00 , Processed in 0.026356 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表