1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

nginx help

Discussion in 'Troubleshooting and Problems' started by Rob, Apr 10, 2012.

  1. Rob

    Rob 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:-
    I believe for first rule above, the following nginx syntax would work ok:-
    Not sure about using permanent AND last but anyway.... how do I do the last .htaccess rule with paging?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Here is the documentation:


    Probably create another rule to match the other pattern (with page numbers). Something like this:

    rewrite ^/forumname-73/sub-forum-name-10/([0-9]+)/$ http://www.mydomain.net/forums/international-midwifery.26/page-$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.
  3. Rob

    Rob 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.
  4. Jake Bunce

    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.
  5. Rob

    Rob Well-Known Member

    This is the rewrite rule for threads:-
    rewrite [^/]+/([\d]+)-.+.html showthread.php?t=$1 last;
  6. Jake Bunce

    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:


  7. Rob

    Rob 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.

Share This Page