.htaccess 301 redirect to other thread

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
User avatar
richey
Registered User
Posts: 636
Joined: Mon Feb 18, 2002 4:26 pm
Location: now@Cyberspace
Contact:

.htaccess 301 redirect to other thread

Post by richey »

Hello,

I'm trying to redirect a soon-to-be deleted thread to another one using .htaccess:

Code: Select all

Redirect 301 /viewtopic.php?t=33996	/viewtopic.php?t=38455
However, that doesn't seem to work (I've put it at the end of the .htaccess file in the phpBB directory).

Any idea what may have gone wrong? I've also tried refreshing the browser, emptying its cache, restarting the browser, loading the URL on another computer and restarting Apache on the server. Still, #33996 is displayed and loaded, but not #38455. :-(
.
User avatar
bonelifer
Community Team Member
Community Team Member
Posts: 3542
Joined: Wed Oct 27, 2004 11:35 pm
Name: William
Contact:

Re: .htaccess 301 redirect to other thread

Post by bonelifer »

Just from searching online this is what I came up with, I'm no rewrite expert.

Change out the "originalForumNumber" for the one the topic shows up in now(this is to catch the two basic permutations a link to a topic could take:

Code: Select all

RewriteEngine On
RewriteCond %{QUERY_STRING} ^f=originalForumNumber&t=33996 [OR]
RewriteCond %{QUERY_STRING} ^t=33996
RewriteRule ^(.*)$ http://yoursite.com/community/viewtopic.php?t=38455 [R=301,L]
William Jacoby - Community Team
Knowledge Base | phpBB Board Rules | Search Customisation Database
Please don't contact me via PM or email for phpBB support .
User avatar
richey
Registered User
Posts: 636
Joined: Mon Feb 18, 2002 4:26 pm
Location: now@Cyberspace
Contact:

Re: .htaccess 301 redirect to other thread

Post by richey »

Thanks, it works that way!

I would have preferred the shorter version, but somehow either the question mark or the equal sign in the string seems to confuse Apache. :?

kind regards
R
.
User avatar
janus_zonstraal
Registered User
Posts: 6414
Joined: Sat Aug 30, 2014 1:30 pm

Re: .htaccess 301 redirect to other thread

Post by janus_zonstraal »

Code: Select all

Redirect 301 /viewtopic.php?t=33996	http://yoursite.com/community/viewtopic.php?t=38455
And this?
Sorry! My English is bat ;) !!!
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26456
Joined: Fri Aug 29, 2008 9:49 am

Re: .htaccess 301 redirect to other thread

Post by Mick »

For the record, there are no threads with phpBB, they are topics.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
User avatar
bonelifer
Community Team Member
Community Team Member
Posts: 3542
Joined: Wed Oct 27, 2004 11:35 pm
Name: William
Contact:

Re: .htaccess 301 redirect to other thread

Post by bonelifer »

richey wrote: Mon Apr 03, 2017 7:44 am Thanks, it works that way!

I would have preferred the shorter version, but somehow either the question mark or the equal sign in the string seems to confuse Apache. :?

kind regards
R
Sure but the longer one catches versions of the link that include the forum parameter, which will likely be cached in the search engines, unless of course you want some links to fail?
William Jacoby - Community Team
Knowledge Base | phpBB Board Rules | Search Customisation Database
Please don't contact me via PM or email for phpBB support .
Post Reply

Return to “[3.2.x] Support Forum”