Nginx + PHP 7 rewrite rules

Hi,

I am trying to setup MyBB forum software using EasyEngine and added php7 stack on it. To get the friendly url working, I need to add an nginx rewrite rules, as showed on this page : http://community.mybb.com/thread-51764.html

I already try to add it to /nginx/common/php7.conf but it does not work.

Any idea on how to solve this problem? Or did I do wrong?

You just have to create a file like mybb.conf in /var/www/yoursite.com/conf/nginx/

and to add the rewrite rules like in your link in this file :

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;

use nginx -t to verify if your config is correct. Then service nginx reload

2 Likes