Welcome to Centmin Mod Community
Become a Member

Xenforo NGINX - Solving Redirect/Rewrite Issues from VBSEO

Discussion in 'Forum software usage' started by ENF, Mar 23, 2017.

  1. ENF

    ENF New Member

    6
    2
    3
    May 9, 2016
    Tokyo, Japan
    Ratings:
    +2
    Local Time:
    3:59 PM
    1.11.9
    MariaDB 10.1.21
    Hi All,

    I'm trying to find the solution to a problem regarding old incoming links that we had in place during the VB 3.x + VBSEO days...

    Previous setup:
    http://forum.domaingoeshere.nnn

    After Conversion to XF (root):
    http://domaingoeshere.nnn

    It seems like that we have redirects (302) working from the old domain setup, but we're facing issues trying to get the incoming links at the main URL to find their way to the correct thread from the older incoming link. (link ends in .html, but contains the the thread ID number)

    Note: We did retain content ID's and have configured the XF/VB3 redirects using the package provided from Xenforo, pointing the to the correct import log table.

    In summary, I'm looking for the correct, working rule to redirect the incoming .html link to the current XF thread.

    Current NGINX config with XF Friendly URL settings (works fine)
    Code:
    location / {
            try_files $uri $uri/ /index.php?$uri&$args;
            index index.php index.html;
    }
    
    location /install/data/ {
            internal;
    }
    location /install/templates/ {
            internal;
    }
    location /internal_data/ {
            internal;
    }
    location /library/ {
            internal;
    }
    
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include         fastcgi_params;
    
    We've tried things like this:
    rewrite [^/]+/([\d]+)-.+-([\d]+).html /showthread.php?t=$1&page=$2 break;
    rewrite [^/]+/([\d]+)-.+.html /showthread.php?t=$1 break;

    etc.. with no luck.

    Looking for input on:
    1. Correct NGINX Directive
    2. Correct position of the Directives in the NGINX .conf file. (above/below rules, etc.)

    We noticed a significant loss of traffic due to old links on referring sites... people just hit a 404 wall instead of getting moved to the correct location.

    Thanks in advance.
     
  2. BamaStangGuy

    BamaStangGuy Active Member

    465
    136
    43
    May 25, 2014
    Ratings:
    +179
    Local Time:
    1:59 AM
    I don't know if this is your problem but it was for us with .html for our vBSEO urls.

    Code:
    nano /usr/local/nginx/conf/staticfiles.conf
    Find:
    Code:
    (html|htm|txt)
    Replace with:
    Code:
    (htm|txt)
    Restart nginx.

    Also, these are our redirect urls in case you still can't get it to work and want to try something else:

    Code:
            rewrite ^/t([\d]+)-([\d]+)/$ /showthread.php?t=$1&page=$2 last;
            rewrite ^/t([\d]+)/$ /showthread.php?t=$1 last;
            rewrite ^/f([\d]+)-([\d]+)/$ /forumdisplay.php?f=$1&page=$2 last;
            rewrite ^/f([\d]+)/$ /forumdisplay.php?f=$1 last;
            rewrite ^/printthread.php?t=([\d]+) /showthread.php?t=$1 last;
     
    • Informative Informative x 2
  3. ENF

    ENF New Member

    6
    2
    3
    May 9, 2016
    Tokyo, Japan
    Ratings:
    +2
    Local Time:
    3:59 PM
    1.11.9
    MariaDB 10.1.21
    @BamaStangGuy - Ok, that's a good starting point... I didn't even consider that. I'll go play around with our config based on your suggestion and see if that solves the issue.

    We did not try this before, but this sounds on target...

    Thank you. I'll come back to confirm if this works.
     
  4. ENF

    ENF New Member

    6
    2
    3
    May 9, 2016
    Tokyo, Japan
    Ratings:
    +2
    Local Time:
    3:59 PM
    1.11.9
    MariaDB 10.1.21
    Update:

    On the old sub-domain, where links still come in, those are being redirected fully correct now.. zero errors or lost clicks there now.

    Still haven't found the right formula to fix links such as:

    http://domaingoeshere.nnn/forum-name-here/32951-this-is-thread-title.html

    These just go to the error page in Xenforo. At least, after the html fix... it's not dropping out to NGINX 404 errors. Now, to figure out the directive to get

    Thanks!
     
    • Like Like x 1