nginx help


Well-known member
I have a test server running nginx and I am trying to get a copy of my site running on it.

I am currently trying to convert some ReWrite Rules over to nginx syntax and am struggling a little...

Here are two example rules:-
RewriteRule ^forumname-73/sub-forum-name-10/$ [R=301,L]

#Forum with paging
ReWriteRule ^forumname-73/sub-forum-name-10/index([\d]+).html$1 [R=301,L]
I believe for first rule above, the following nginx syntax would work ok:-
rewrite ^/forumname-73/sub-forum-name-10/$ permanent last;
Not sure about using permanent AND last but anyway.... how do I do the last .htaccess rule with paging?

Jake Bunce

XenForo moderator
Staff member
Here is the documentation:

how do I do the last .htaccess rule with paging?
Probably create another rule to match the other pattern (with page numbers). Something like this:

rewrite ^/forumname-73/sub-forum-name-10/([0-9]+)/$$1 permanent;
This is assuming original 'page' URLs like this:

/forumname-73/sub-forum-name-10/page number here/

The regex depends on the format of the original URL.


Well-known member
I am routing these via the Kier's redirection pages and the trouble I am getting is that showthread.php and forumdisplay.php are being appended to the path.
An old vbseo url for a thread seems to be rewritten to the same url but the latter part being swapped for showthread.php ... grrrr.... same for forums.

I need to sort this but something, somewhere is very wrong. That documentation hasn't helped much tbh.

Jake Bunce

XenForo moderator
Staff member
What rewrite rule are you using to map the URLs to the redirect scripts? Because the examples you posted don't use those scripts.

Jake Bunce

XenForo moderator
Staff member
Instead of ([\d]+) you might try ([0-9]+). I have found this to be necessary on some servers.

And technically you should escape the "." in ".html":


You mentioned the file names are appended to the path. I'm not quite sure what that means. But you can try using a full URL for the location. Instead of showthread.php?t=$1 use http://www.....showthread.php?t=$1. Or this might be relevant:

If in the line of replacement arguments are indicated, then the rest of the request arguments are appended to them. To avoid having them appended, place a question mark as the last character:

rewrite ^/users/(.*)$ /show?user=$1? last;


Well-known member
Ok, I have got this working, I think its because i left out the slash in front of showthread. In fact, I got rid of showthread altogether for threads since its not nessesary when a thread doesnt using paging (ie, when on page 1)...

Here are my rules for regular threads and threads with paging
#threads with paging
rewrite [^/]+/([\d]+)-.+-([\d]+).html /showthread.php?t=$1&page=$2 last;
#regular threads
rewrite [^/]+/([\d]+)-.+.html /threads/.$1/ permanent;
Obviously, I have my xF and old vB set to the same number of threads per page and also I think I modified Kier's script a little.