PHP Redirect of vbulletin urls to phpbb forum

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
TheDude2
Registered User
Posts: 7
Joined: Wed Mar 21, 2018 2:14 am
Contact:

PHP Redirect of vbulletin urls to phpbb forum

Post by TheDude2 » Sat Mar 31, 2018 11:39 pm

I am trying to redirect some urls that were used under vBulletin but I can't get the PHP code to work
if any number is in the url p value I want it to pass through to the t value - that part works fine,
but when the value is equal to 724166 then I want the $forum value changed to 2330,
that part does not work.

any help would be appreciated.

Code: Select all

<?php
if (!empty($_GET['p']))
{
    $forum = (int) $_GET['p'];
    if ($forum = 724166)
    {$forum = 2330}
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://hundredbling.net/viewtopic.php?t=' . $forum);
}
?>

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1968
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: PHP Redirect of vbulletin urls to phpbb forum

Post by kinerity » Sun Apr 01, 2018 4:18 am

http://hundredbling.net/viewtopic.php?t=724166 and http://hundredbling.net/viewtopic.php?t=2330 shows
Information

The requested topic does not exist.
Kailey Truscott - Community Team

TheDude2
Registered User
Posts: 7
Joined: Wed Mar 21, 2018 2:14 am
Contact:

Re: PHP Redirect of vbulletin urls to phpbb forum

Post by TheDude2 » Sun Apr 01, 2018 6:09 am

the 2nd one I just made up but if it makes a difference here is an actual url to use:

http://hundredbling.net/viewtopic.php?t=217800

and http://hundredbling.net/viewtopic.php?t=724166 does not exist, that's why I want to change it to one that does.

User avatar
AmigoJack
Registered User
Posts: 5384
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PHP Redirect of vbulletin urls to phpbb forum

Post by AmigoJack » Wed Apr 04, 2018 7:15 am

TheDude2 wrote:
Sat Mar 31, 2018 11:39 pm

Code: Select all

    if ($forum = 724166)
That's an assignment, no comparison. Assignments always evaluate to TRUE.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
mrgoldy
Jr. Extension Validator
Posts: 734
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: PHP Redirect of vbulletin urls to phpbb forum

Post by mrgoldy » Sat Apr 07, 2018 8:56 am

In addition to what Jack said, you are also missing a semi-colon (;).

Code: Select all

<?php

$forum = (int) $_GET['p'];

if (!empty($forum))
{
    if ($forum == 724166)
    {
    	$forum = 2330;
    }
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://hundredbling.net/viewtopic.php?t=' . $forum);
}
?>
And what confuses me, is that the variable is named forum but you do not use the f parameter and viewforum in your redirect URL, but the t and viewtopic, which is used by phpBB for topics. Is that correct?
Formerly known as posey.
''Proud member of the Studio"

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: Chico Gois and 10 guests