Any Nginx config experts anywhere?


Well-known member
Hi there,

I have moved from apache/vb/vbseo to nginx/xenforo.

I am struggling to optimise my nginx config file and have so far received some generous help from Floren but am now scratching my head over how to proceed further.

I cannot pay anyone for this so I'm relying on the generosity of xenForo users to steer me in the right direction.

What I need is to be able to optimise the following nginx config
#Forum 26 main
location = /category-name-73/forum-name-26/  {
    rewrite ^ /forums/forum-name.26/ permanent;
#Forum 26
location /category-name-73/forum-name-26/ {
    #forum paging
    rewrite ^/category-name-73/forum-name-26/index([\d]+).html /forums/forum-name.26/page-$1 permanent;
    #thread paging (modified version of kier's redirect script)
    rewrite [^/]+/([\d]+)-.+-([\d]+).html /showthread.php?t=$1&page=$2 last;
    rewrite [^/]+/([\d]+)-.+.html /threads/redirectme.$1/ permanent;
I've been told that when hitting "/category-name-73/forum-name-26/" then 4 regex's will be evaluated and supposedly that is not good. If I hit a deeper url at the same path then I'm told it will evaluate 3 regex's. However, it is apparently possible to do the above using just one regex. I am purplexed as to how this would be possible and clearly want to have the most optimised config I can but I now seem stuck in no mans land.

Can anyone please help me?


Well-known member
Thank you... shame the tag me mod isnt installed here :)

The above is just a very very small part of a huge config file migrated from a .htaccess file which rewrites old vbseo urls to xenforo under apache.

If I can optimise just this small part then I can handle the rest of the config on my own :)


Well-known member

I was mainly trying to avoid the 4 regex calls for urls in the path above. Floren has told me there is much better way than going the above route but hasnt really gave me anything else to go on.

I agree that the reg ex shouldn't really be that much of an overhead but I want to start out with as optimised a config as possible.

If I can implement this with minimal reg ex use then I doubt PCRE JIT will be needed at all.

Can the above be tweaked to make use of nested location {} elements to be 'more selective'? I can see how to select paths using forum paging, but I can't see how to select paths for threads or thread paging using just location {} as the selector. If I can sort out that bit then I can ensure just one reg ex is run per url.

I think this thread could be extremely useful to other people who have moved to nginx and need to rewrite vbseo urls.

Any ideas?