converting apache rewrite rules to nginx for xenforo
Posted
by
nick
on Server Fault
See other posts from Server Fault
or by nick
Published on 2011-01-07T22:22:19Z
Indexed on
2011/01/07
22:55 UTC
Read the original article
Hit count: 199
Hi all, I am migrating some forums from vbulletin 3.8.x to xenforo, and trying to keep my old link structure alive. Basically, XF provides some php files that I can redirect the old url style to and it handles the proper 301 redirection.
Regardless of that end, I am having difficulty rewriting the rules which I can only find defined in apache's rewrite style:
RewriteRule [\d]+-[^/]+/.+-([\d]+)/([\d]+)/ showthread.php?t=$1&page=$2 [NC,L]
RewriteRule [\d]+-[^/]+/.+-([\d]+)/ showthread.php?t=$1 [NC,L]
RewriteRule ([\d]+)-[^/]+/([\d]+)/ forumdisplay.php?f=$1&page=$2 [NC,L]
RewriteRule ([\d]+)-[^/]+/ forumdisplay.php?f=$1 [NC,L]
I have been experimenting and thought this should work, but obviously not:
if (!-e $request_filename) {
rewrite [0-9a-zA-Z\-]/[0-9a-zA-Z\-]-([0-9])/([0-9])/ /showthread.php?t=$1&page=$2 last;
rewrite [0-9a-zA-Z\-]/[0-9a-zA-Z\-]-([0-9])/ /showthread.php?t=$1 last;
rewrite ([0-9])-[0-9a-zA-Z\-]/([0-9])/ /forumdisplay.php?f=$1&page=$2 last;
rewrite ([0-9])-[0-9a-zA-Z\-]/ /forumdisplay.php?f=$1 last;
rewrite ^(.*)$ /index.php last;
}
old vB showthread format: website.tld/233-website-issues-requests/wiki-down-73789/
new XF showthread format: website.tld/threads/the-wiki-is-down.65509/
old vB forumdisplay format: website.tld/233-website-issues-requests/
new XF forumdisplay format: website.tld/forums/website-issues-and-requests.253/
© Server Fault or respective owner