.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: 608
Joined: Mon Feb 18, 2002 4:26 pm
Location: now@Cyberspace
Contact:

.htaccess 301 redirect to other thread

Post by richey » Mon Apr 03, 2017 12:16 am

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: 3403
Joined: Wed Oct 27, 2004 11:35 pm
Name: William
Contact:

Re: .htaccess 301 redirect to other thread

Post by bonelifer » Mon Apr 03, 2017 2:11 am

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]
Knowledge Base | phpBB Board Rules | Search Customisation Database
Image
Please don't contact me via PM or email for phpBB support .

User avatar
richey
Registered User
Posts: 608
Joined: Mon Feb 18, 2002 4:26 pm
Location: now@Cyberspace
Contact:

Re: .htaccess 301 redirect to other thread

Post by richey » 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
.

janus_zonstraal
Registered User
Posts: 2690
Joined: Sat Aug 30, 2014 1:30 pm

Re: .htaccess 301 redirect to other thread

Post by janus_zonstraal » Mon Apr 03, 2017 8:39 am

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: 20237
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: .htaccess 301 redirect to other thread

Post by Mick » Mon Apr 03, 2017 11:35 am

For the record, there are no threads with phpBB, they are topics.
"The more connected we get the more alone we become" - Kyle Broflovski

There are no ‘threads’ in phpBB, they are topics.

User avatar
bonelifer
Community Team Member
Community Team Member
Posts: 3403
Joined: Wed Oct 27, 2004 11:35 pm
Name: William
Contact:

Re: .htaccess 301 redirect to other thread

Post by bonelifer » Mon Apr 03, 2017 3:51 pm

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?
Knowledge Base | phpBB Board Rules | Search Customisation Database
Image
Please don't contact me via PM or email for phpBB support .

Post Reply

Return to “[3.2.x] Support Forum”

Who is online

Users browsing this forum: Brf, Contergantreff, Crizzo, Lumpy Burgertushie and 47 guests