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-(+)\.html$ /MyBB/forumdisplay.php?fid=$1;
rewrite ^/MyBB/forum-(+)-page-(+)\.html$ /MyBB/forumdisplay.php?fid=$1&page=$2;
rewrite ^/MyBB/thread-(+)\.html$ /MyBB/showthread.php?tid=$1;
rewrite ^/MyBB/thread-(+)-page-(+)\.html$ /MyBB/showthread.php?tid=$1&page=$2;
rewrite ^/MyBB/thread-(+)-lastpost\.html$ /MyBB/showthread.php?tid=$1&action=lastpost;
rewrite ^/MyBB/thread-(+)-nextnewest\.html$ /MyBB/showthread.php?tid=$1&action=nextnewest;
rewrite ^/MyBB/thread-(+)-nextoldest\.html$ /MyBB/showthread.php?tid=$1&action=nextoldest;
rewrite ^/MyBB/thread-(+)-newpost\.html$ /MyBB/showthread.php?tid=$1&action=newpost;
rewrite ^/MyBB/thread-(+)-post-(+)\.html$ /MyBB/showthread.php?tid=$1&pid=$2;
rewrite ^/MyBB/post-(+)\.html$ /MyBB/showthread.php?pid=$1;
rewrite ^/MyBB/announcement-(+)\.html$ /MyBB/announcements.php?aid=$1;
rewrite ^/MyBB/user-(+)\.html$ /MyBB/member.php?action=profile&uid=$1;
rewrite ^/MyBB/calendar-(+)\.html$ /MyBB/calendar.php?calendar=$1;
rewrite ^/MyBB/calendar-(+)-year-(+)\.html$ /MyBB/calendar.php?action=yearview&calendar=$1&year=$2;
rewrite ^/MyBB/calendar-(+)-year-(+)-month-(+)\.html$ /MyBB/calendar.php?calendar=$1&year=$2&month=$3;
rewrite ^/MyBB/calendar-(+)-year-(+)-month-(+)-day-(+)\.html$ /MyBB/calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4;
rewrite ^/MyBB/calendar-(+)-week-(n?+)\.html$ /MyBB/calendar.php?action=weekview&calendar=$1&week=$2;
rewrite ^/MyBB/event-(+)\.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 编辑 ] 为什么要开伪静态?现在的搜索引擎谁不认识动态网页?,伪静态,纯属多余.还消耗资源. 对SEO有很大好处。谁用谁知道
页:
[1]