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

VBSEO --> XF Rewrite Rules for Nginx?

Discussion in 'Installation, Upgrade, and Import Support' started by Coop1979, May 29, 2012.

  1. Coop1979

    Coop1979 Well-Known Member

    I'm finishing up an import from vB 3.8 + VBSEO and am trying to setup the rewrite rules for Nginx. Here are the rules for Apache:

    Code:
    RewriteRule [^/]+/([\d]+)-.+-([\d]+).html showthread.php?t=$1&page=$2 [NC,L]
    RewriteRule [^/]+/([\d]+)-.+.html showthread.php?t=$1 [NC,L]
    I tried using this site to convert the RewriteRules, but this rewrite doesn't seem to be working. Any ideas?

    Code:
            location /forums {
            rewrite ^/forums/[^/]+/([d]+)-.+.html /showthread.php?t=$1 last;
    }
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Instead of:

    ([d]+)

    Try:

    ([0-9]+)

    Or:

    (\d+)

    Also try getting rid of the directory name in your rewrite. So overall try this:

    Code:
    location /forums/ {
    	rewrite [^/]+/([0-9]+)-.+\.html /forums/showthread.php?t=$1 last;
    }
    
     
    Coop1979 likes this.
  3. Coop1979

    Coop1979 Well-Known Member

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Here is for thread paging:

    Code:
    location /forums/ {
    	rewrite [^/]+/([0-9]+)-.+-([0-9]+)\.html /forums/showthread.php?t=$1&page=$2 last;
    }
    
    Use this:

    Code:
    location /forums/ {
    	rewrite my-forum /forums/51 permanent;
    }
    
     
    Coop1979 likes this.
  5. Coop1979

    Coop1979 Well-Known Member

    That works great. Next time I'm in SD, beers are on me.
     
  6. Coop1979

    Coop1979 Well-Known Member

    Ran into an un-anticipated hiccup with some links this morning. If the vbSEO link is a direct link to a post, it appends "#post1234" to the end of the link. The url redirection carries that "#post1234" through in the url, but in order for XenForo to actually go to the correct post, the end of the url needs to be formatted as "#post-1234".

    For example, the redirected link is currently this:

    Code:
    http://mysite.com/threads/18-000-please-help-me.88518/#post1241833
    But needs to be this:
    Code:
    http://mysite.com/threads/18-000-please-help-me.88518/#post-1241833
    How can I add that '-' to the redirected link using my Nginx re-write rule?
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page