SOLVED: Redirect topic/thread to new URL using htaccess

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
mamba
Registered User
Posts: 507
Joined: Thu Jan 16, 2003 7:59 pm

SOLVED: Redirect topic/thread to new URL using htaccess

Post by mamba »

Hi

I need to redirect a single topic to a completely different URL on another site.

So this

http://www.example.com/forum/viewtopic.php?f=4&t=7882

must become this

http://www.foo.com

Unsure of whether to use Apache's Redirect or Rewrite :?:

Anyone have any ideas?
Last edited by mamba on Tue Jul 16, 2013 3:49 am, edited 1 time in total.
Using 3.3, PHP version 7.3, MySQL 5.6, Host: HawkHost shared Linux, Style: Prosilver
User avatar
mamba
Registered User
Posts: 507
Joined: Thu Jan 16, 2003 7:59 pm

Re: Redirect single topic/thread to new URL using htaccess

Post by mamba »

Just FYI, this does not work

Code: Select all

# 302 Redirect Old File
Redirect 302 http://www.example.com/forum/viewtopic.php?f=4&t=7882 http://www.foo.com
Nor does this

Code: Select all

RedirectMatch 302 viewtopic\.php\?f=4&t=7882 http://www.foo.com
Using 3.3, PHP version 7.3, MySQL 5.6, Host: HawkHost shared Linux, Style: Prosilver
User avatar
mamba
Registered User
Posts: 507
Joined: Thu Jan 16, 2003 7:59 pm

Re: Redirect single topic/thread to new URL using htaccess

Post by mamba »

This works

Code: Select all

RewriteEngine On
RewriteCond %{QUERY_STRING} t=7882
RewriteCond %{QUERY_STRING} f=4
RewriteRule ^(.*)$ http://www.foo.com/? [R=301,L]
Thanks for all the help.
Using 3.3, PHP version 7.3, MySQL 5.6, Host: HawkHost shared Linux, Style: Prosilver
User avatar
Volksdevil
Registered User
Posts: 2414
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil
Contact:

Re: Redirect single topic/thread to new URL using htaccess

Post by Volksdevil »

mamba wrote:Just FYI, this does not work

Code: Select all

# 302 Redirect Old File
Redirect 302 http://www.example.com/forum/viewtopic.php?f=4&t=7882 http://www.foo.com
Nor does this

Code: Select all

RedirectMatch 302 viewtopic\.php\?f=4&t=7882 http://www.foo.com
You shouldn't use an 'absolute' URL initially. Below should work on Linux.
Redirect 301 [color=#FF0000]/OLD.php[/color] [color=#0000FF]http://www.NEW.php[/color]

Edit: Of course you firstly need

Code: Select all

RewriteEngine on
RewriteBase /
My phpBB Extensions
Finally found great Website Hosting from Image KUALO!
Do NOT use 123-reg.co.uk - Incapable of running phpBB!
:ugeek: TekNeil - Streamer on Mixer | My Volkswagen Corrado G60
User avatar
ViolaF
Registered User
Posts: 1526
Joined: Tue Aug 14, 2012 11:52 pm

Re: Redirect single topic/thread to new URL using htaccess

Post by ViolaF »

도서관
marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: Redirect single topic/thread to new URL using htaccess

Post by marian0810 »

ViolaF wrote:도서관
Please post in English only.

https://www.phpbb.com/rules/#english-language
You and me, time and space. You watch us run!
User avatar
mamba
Registered User
Posts: 507
Joined: Thu Jan 16, 2003 7:59 pm

Re: Redirect single topic/thread to new URL using htaccess

Post by mamba »

Volksdevil wrote: You shouldn't use an 'absolute' URL initially. Below should work on Linux.
Redirect 301 [color=#FF0000]/OLD.php[/color] [color=#0000FF]http://www.NEW.php[/color]
It does not work with the complex URL I supplied above. My solution works, problem solved.
Using 3.3, PHP version 7.3, MySQL 5.6, Host: HawkHost shared Linux, Style: Prosilver
User avatar
ViolaF
Registered User
Posts: 1526
Joined: Tue Aug 14, 2012 11:52 pm

Re: SOLVED: Redirect topic/thread to new URL using htaccess

Post by ViolaF »

marian0810 wrote:
ViolaF wrote:도서관
Please post in English only.

https://www.phpbb.com/rules/#english-language
viewtopic.php?p=13343725#p13343725
User avatar
Lumpy Burgertushie
Registered User
Posts: 67994
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: SOLVED: Redirect topic/thread to new URL using htaccess

Post by Lumpy Burgertushie »

ViolaF wrote:
marian0810 wrote:
ViolaF wrote:도서관
Please post in English only.

https://www.phpbb.com/rules/#english-language
viewtopic.php?p=13343725#p13343725
what does that link have to do with this topic?

it is not about the same thing this topic is about and it is not about what marion posted about you posing in english only.

are you just randomly posting things?

robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?
marian0810
Former Team Member
Posts: 3011
Joined: Mon May 21, 2007 9:17 pm
Location: The Netherlands
Name: Marian
Contact:

Re: SOLVED: Redirect topic/thread to new URL using htaccess

Post by marian0810 »

That's okay I get it :) It was an error in her phone.
You and me, time and space. You watch us run!
User avatar
Volksdevil
Registered User
Posts: 2414
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil
Contact:

Re: Redirect single topic/thread to new URL using htaccess

Post by Volksdevil »

mamba wrote:
Volksdevil wrote: You shouldn't use an 'absolute' URL initially. Below should work on Linux.
Redirect 301 [color=#FF0000]/OLD.php[/color] [color=#0000FF]http://www.NEW.php[/color]
It does not work with the complex URL I supplied above. My solution works, problem solved.
Ah, it's the ampersand causing the issue. I just rewrite direct to the topic id without the 'p' parameter or ampersand. If you need to do that though, then I'm glad your solution works for you.
My phpBB Extensions
Finally found great Website Hosting from Image KUALO!
Do NOT use 123-reg.co.uk - Incapable of running phpBB!
:ugeek: TekNeil - Streamer on Mixer | My Volkswagen Corrado G60
Locked

Return to “[3.0.x] MOD Writers Discussion”