• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Redirects not working

mistypants

Well-known member
#1
Hi all,

We moved our site ( http://www.kh-vids.net/ ) to XenForo in August of 2012. I set up redirects back then and they were all working fine. Recently we had a small hack (nothing major or related to XF, they deleted a few files, everything's been locked down since), and our redirects broke (they deleted the redirect files). I've been trying to fix it no avail.

I've reuploaded everything from here: http://xenforo.com/community/resources/vbulletin-4-x-url-redirection.120/
And updated 301config.php as described here.

Still, old URLs are just redirecting to the homepage. :( Any ideas?

For the record, here's some old links:
http://www.kh-vids.net/forumdisplay.php?2-The-Rules
http://www.kh-vids.net/showthread.php?120155-The-KH-Vids-User-Survey
http://www.kh-vids.net/member.php?15943-Mr-Pumpkin
 

Jake Bunce

XenForo moderator
Staff member
#2
Still, old URLs are just redirecting to the homepage. :( Any ideas?
Confirm the name of the import log table in the database. It's usually named xf_import_log or archived_import_log. Then specify that name in the 301config.php file. If the table name is incorrect then it will result in all redirects going to the forum index.
 

mistypants

Well-known member
#4
Confirm the name of the import log table in the database. It's usually named xf_import_log or archived_import_log. Then specify that name in the 301config.php file. If the table name is incorrect then it will result in all redirects going to the forum index.
Doh, that was it! I added the name of the table but I forgot to uncomment the line.

Thanks a lot.
 
#5
Confirm the name of the import log table in the database. It's usually named xf_import_log or archived_import_log. Then specify that name in the 301config.php file. If the table name is incorrect then it will result in all redirects going to the forum index.
Hi Jake ... would you mind helping me with the same?

My redirects have been working fine, but they're redirecting to my home page now. I don't see any reason why things changed. I've confirmed the above and all is well. Any suggestions on how I can get them to work properly again?

Thanks in advance.
 

Jake Bunce

XenForo moderator
Staff member
#6
Hi Jake ... would you mind helping me with the same?

My redirects have been working fine, but they're redirecting to my home page now. I don't see any reason why things changed. I've confirmed the above and all is well. Any suggestions on how I can get them to work properly again?

Thanks in advance.
I need FTP access to your server to confirm the table name and check the 301config.php file. You can PM me.
 

Jake Bunce

XenForo moderator
Staff member
#7
The old thread links are using the vB2 format:

showthread.php?s=&threadid=4

You will notice that it works if you use this:

showthread.php?s=&t=4

I have modified the showthread.php file to check for 'threadid' as well:

Code:
<?php

$startTime = microtime(true);

$fileDir = dirname(__FILE__);
if (file_exists($fileDir . '/301config.php'))
{
	include($fileDir . '/301config.php');
}

require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');

XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);

$inputHandler = new XenForo_Input(new Zend_Controller_Request_Http());

$input = $inputHandler->filter(array(
	't' => XenForo_Input::UINT,
	'p' => XenForo_Input::UINT,
	'threadid' => XenForo_Input::UINT
));

$importModel = XenForo_Model::create('XenForo_Model_Import');

$target = false;
if ($input['t'])
{
	if ($newId = $importModel->mapThreadId($input['t']))
	{
		$target = XenForo_Link::buildPublicLink('canonical:threads', array('thread_id' => $newId));
	}
}
else if ($input['threadid'])
{
	if ($newId = $importModel->mapThreadId($input['threadid']))
	{
		$target = XenForo_Link::buildPublicLink('canonical:threads', array('thread_id' => $newId));
	}
}
else if ($input['p'])
{
	$newId = $importModel->mapPostId($input['p']);
	if ($newId)
	{
		$target = XenForo_Link::buildPublicLink('canonical:posts', array('post_id' => $newId));
	}
}

if (!$target)
{
	$target = XenForo_Link::buildPublicLink('canonical:index');
}

$response = new Zend_Controller_Response_Http();
$response->setRedirect(XenForo_Link::convertUriToAbsoluteUri($target), 301);
$response->sendResponse();
It works now.