I recently migrated a forum from Simple Machines to Xenforo and needed to rewrite the SMF urls to Xenforo urls.
Old url: domain.com/forum/index.php/topic,101126.msg38.html
Rewritten url: domain.com/forum/index.php?posts/38
Here's my Nginx rewrite rule:
rewrite /forum/index\.php/topic,[0-9]+\.\bmsg([0-9]+)\.html /forum/index.php?posts/$1 redirect;
However, when I apply this to my Centmin Vhost file, it doesn't work. After much trial and error, I realized
the issue is in the global file include /usr/local/nginx/conf/staticfiles.conf;
The rewrite works perfectly if I do either of the following:
a) strip .html from both the old url and the rewrite regex.
b) comment out this include.
Option A is impossible since I've got thousands of inbound links that include the .html
After looking at what's in staticfiles.conf, I'd prefer to avoid option B because there's a lot of useful stuff in there...
Is there any way this global file can be tweaked to allow rewriting links in the vhost config files that point to .html files?
I suspect I could just edit staticfiles.conf and put the rewrite in there, but I'd prefer to avoid that to allow my vhost files to stay localized and not touch global centminmod configs so that it's easy to upgrade later...
I'm on Centminmod .008 beta because I wanted to use Centos 7.
I recently migrated a forum from Simple Machines to Xenforo and needed to rewrite the SMF urls to Xenforo urls.
Old url:
domain.com/forum/index.php/topic,101126.msg38.htmlRewritten url:
domain.com/forum/index.php?posts/38Here's my Nginx rewrite rule:
rewrite /forum/index\.php/topic,[0-9]+\.\bmsg([0-9]+)\.html /forum/index.php?posts/$1 redirect;However, when I apply this to my Centmin Vhost file, it doesn't work. After much trial and error, I realized
the issue is in the global file
include /usr/local/nginx/conf/staticfiles.conf;The rewrite works perfectly if I do either of the following:
a) strip
.htmlfrom both the old url and the rewrite regex.b) comment out this include.
Option A is impossible since I've got thousands of inbound links that include the .html
After looking at what's in
staticfiles.conf, I'd prefer to avoid option B because there's a lot of useful stuff in there...Is there any way this global file can be tweaked to allow rewriting links in the vhost config files that point to .html files?
I suspect I could just edit
staticfiles.confand put the rewrite in there, but I'd prefer to avoid that to allow my vhost files to stay localized and not touch global centminmod configs so that it's easy to upgrade later...I'm on Centminmod .008 beta because I wanted to use Centos 7.