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

rebelde

Active 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!
 
Add this to the top of your .htaccess

RewriteEngine On
RewriteCond %{QUERY_STRING} p=([0-9]+)(&|$)
RewriteRule showthread\.php$ posts/%1? [R=301,L]
 
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.
 
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.
 
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;
}
 
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;
    }
}
 
Top Bottom