Note: this is not a plugin problem, the patches plugin works fine, it's just the rewrites not working correctly
Hihi,
A while back I used frostschutz's patches plugin to create some basic Nginx rewrites such as /user-1, thread-5 etc etc...
On a fresh Nginx install, with the latest MyBB and patches plugin, the following more advanced rewrites don't seem to be working.
define('THREAD_URL_PAGED', 'thread-{tid}-page-{page}');
And in my Nginx VHOST I use the following in a location / block:
rewrite ^(?i)/thread-([0-9]+)-page-([0-9]+)$ /showthread.php?tid=$1&page=$2;
The same also happens with forum pagination, resulting in invalid forum error messages.
define('FORUM_URL_PAGED', 'forum-{fid}-page-{page}');
Nginx rewrite:
rewrite ^(?i)/forum-([0-9]+)$-page-([0-9]+)$ /forumdisplay.php?fid=$1&page=$2;
Any ideas?
Can you check the access log/error log to see what the rewrites are resulting in?
(2016-05-15, 08:57 PM)Euan T Wrote: [ -> ]Can you check the access log/error log to see what the rewrites are resulting in?
[15/May/2016:15:58:38 -0500] "GET /forum-17-page-4 HTTP/2.0" 200 4253 "https://domain.com/forum-17"
Looks like it doesn't like $2, ever.
[15/May/2016:16:00:06 -0500] "GET /thread-4-page-2 HTTP/2.0" 200 4262 "https://domain.com/thread-4"
Well, the problem with the forum one is your use of "$":
rewrite ^/forum-([0-9]+)-page-([0-9]+)$ /forumdisplay.php?fid=$1&page=$2;
Not sure about the thread one though.
(2016-05-15, 09:35 PM)Euan T Wrote: [ -> ]Well, the problem with the forum one is your use of "$":
rewrite ^/forum-([0-9]+)-page-([0-9]+)$ /forumdisplay.php?fid=$1&page=$2;
Not sure about the thread one though.
Applied that in my VHOST and restarted Nginx but still the same errors with forum pagination.
From your server logs, it looks like it's matching the rewrites for the non-paged stuff first. move the rewrites for pages above the rewrites for non-paged and it should work.
maybe there is no $ at the end of your regex for your non-pages rewrites?
(2016-05-18, 01:10 PM)frostschutz Wrote: [ -> ]maybe there is no $ at the end of your regex for your non-pages rewrites?
As Nekomimi mentioned above, it was simply the order of the rules in my configuration file that was the problem.
location / {
try_files $uri $uri/ @extensionless-php;
rewrite ^(?i)/forum-([0-9]+)-page-([0-9]+)$ /forumdisplay.php?fid=$1&page=$2;
rewrite ^(?i)/thread-([0-9]+)-page-([0-9]+)$ /showthread.php?tid=$1&page=$2;
rewrite ^(?i)/thread-([0-9]+)-post-([0-9]+)$ /showthread.php?tid=$1&pid=$2;
rewrite ^(?i)/thread-([0-9]+)-lastpost$ /showthread.php?tid=$1&action=lastpost;
rewrite ^(?i)/thread-([0-9]+)-newpost$ /showthread.php?tid=$1&action=newpost;
rewrite ^(?i)/thread-([0-9]+)-nextnewest$ /showthread.php?tid=$1&action=nextnewest;
rewrite ^(?i)/thread-([0-9]+)-nextoldest$ /showthread.php?tid=$1&action=nextoldest;
rewrite ^(?i)/help /misc.php?action=help;
rewrite ^/(?i)thread-(.*)/(.*)$ /thread-$1 permanent;
rewrite ^/(?i)user-(.*)/(.*)$ /user-$1 permanent;
rewrite ^/(?i)post-(.*)/(.*)$ /post-$1 permanent;
rewrite ^/(?i)forum-(.*)/(.*)$ /forum-$1 permanent;
rewrite ^/(?i)user-(.*)$ /member.php?action=profile&uid=$1& last;
rewrite ^/(?i)thread-(.*)$ /showthread.php?tid=$1& last;
rewrite ^/(?i)forum-(.*)$ /forumdisplay.php?fid=$1& last;
rewrite ^/(?i)post-(.*)$ /showthread.php?pid=$1& last;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
Well, there's the problem - you're using a greedy capture for everything ("(.*) will match everything).
(2016-05-18, 01:26 PM)Euan T Wrote: [ -> ]Well, there's the problem - you're using a greedy capture for everything ("(.*) will match everything).
Using ([0-9]+) in lieu of (.*)/(.*) will work fine for those last 8 rules right?