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

XF 1.4 /showthread.php?t=3008412&p=15214373 > /posts/15214373/

Discussion in 'Installation, Upgrade, and Import Support' started by rebelde, May 11, 2015.

  1. rebelde

    rebelde Member

    Hi,

    New conversion from vB.

    Redirects are working except in this case:
    /showthread.php?t=3008412&p=15214373
    redirects to:
    /threads/3008412/

    Of course it is not pointing to the right post now.
    It would work better if it were to redirect to:
    /posts/15214373/

    Which then goes to the proper post in the thread.

    How can I change the way that this works? I can't find the code that does the redirection.

    Thanks!
     
  2. Slavik

    Slavik XenForo Moderator Staff Member

    Add this to the top of your .htaccess

    RewriteEngine On
    RewriteCond %{QUERY_STRING} p=([0-9]+)(&|$)
    RewriteRule showthread\.php$ posts/%1? [R=301,L]
     
  3. rebelde

    rebelde Member

    I am using Nginx and the rewrite rule was ignored:
    rewrite ^/showthread.php?t=([0-9])*&p=([0-9]*)$ /posts/$2/ permanent;​

    It seems to intercept and redirect before it ever gets to that rule.
     
  4. rebelde

    rebelde Member

    Argh! Nginx doesn't let you do something as easy as including the query string in a simple rewrite rule like that! Handling of the query string arguments is more complex.
     
  5. EQnoble

    EQnoble Well-Known Member

    Have you tried something like this?

    Code:
    if ($args ~ "p=([0-9]+)(&|$)"){
        set $rule_0 1$rule_0;
        set $bref_1 $1;
    }
    if ($rule_0 = "1"){
        rewrite /showthread.php$ /posts/$bref_1? permanent;
    }
    
     
  6. rebelde

    rebelde Member

    Yes, that looks like the more complicated code that I need. Do you use it and does it work for you?
     
  7. EQnoble

    EQnoble Well-Known Member

    No I don't have an nginx box up right now that I can test things with, just suggesting some thing to try since things weren't working for you as it was.

    Have you tried using the location directive?

    Something like this?

    Code:
    location / {
        if ($query_string ~ "p=([0-9]+)(&|$)"){
            rewrite showthread\.php$ /posts/%1? redirect;
        }
    }
     
  8. rebelde

    rebelde Member

    Thanks. I haven't tried anything else just yet. I realize that I need to do some studying to understand how it works before I try again.
     
  9. EQnoble

    EQnoble Well-Known Member

    Last edited: May 12, 2015
  10. rebelde

    rebelde Member

    For future reference,

    We have a showthead.php file that handles this. It was right there in the html root all along. A quick edit took care of it.
     

Share This Page