• 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/

#1
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!
 

Slavik

XenForo moderator
Staff member
#2
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
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
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.
 

EQnoble

Well-known member
#5
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.
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;
}
 

EQnoble

Well-known member
#7
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
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.
 
#10
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.