The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
404 / 301 after import redirect on import ids Details »» | |||||||||||||||||||||||||||
404 / 301 after import redirect on import ids
Developer Last Online: Oct 2010
After importing from a source board there will be internal and external links that point to the old URLS.
During the import the origional import id's are kept (for one import) so a redirect can be calculated to find the new user/forum/thread/post, by looking up the old import{$type}id. ImpEx currently alters the table to add the import id, though a planned future version will have this separated so multi-import sites can be managed, The original discussion thread on vBulletin.com : http://www.vbulletin.com/forum/showthread.php?t=178161 It is advised that $do_404 = false; is set so the 301 is sent with the new URL to update search engines. The script needs setting up and customising to each site as the domains and URLs can be different. Show Your Support
|
Comments |
#32
|
|||
|
|||
Indeed, I copied/pasted wrong but fixed above. Threads look like this:
http://mysite.com/index.php/topic,775.0.html I have pretty much no programming experience so while appreciate your valiant effort, it doesn't look like I'll get very far although I'm going to give it a try. |
#33
|
|||
|
|||
A friend took a look and here is what they came up with. I'm hoping someone can go over it and see if it is okay as I can't really "test" the 301 redirect until I'm live with the new site. Greatly appreciate your help
This sets the variables we use below to determine if we need to parse the old urls. Code:
case 'smf' $old_forum_script = "index.php?board="; //http://mysite.com/index.php?board=5.0 $old_thread_script = "index.php/topic,"; //http://mysite.com/index.php/topic,775.0.html $old_post_script = ".msg"; //http://mysite.com/index.php/topic,603.msg6020.html#new $old_user_script = "index.php?action=profile,u="; //http://mysite.com/index.php?action=profile;u=41 break; Forum Link - Tell it to grab the querystring value for 'board' Code:
// It's a forum link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}{$old_forum_script}") === 0) { $action = 'forum'; $old_id = intval($_GET['board']); $sql = "SELECT forumid FROM {$tableprefix}forum WHERE importforumid={$old_id}"; } Thread Link - Tell it to grab the int value for thread id Code:
// It's a thread link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}{$old_thread_script}") === 0) { $action = 'thread'; // Cuts 775 out of this : /index.php/topic,775.0.html $old_id = intval(substr(substr($_SERVER['REQUEST_URI'], 17), 0, strpos(substr($_SERVER['REQUEST_URI'], 17), '.'))); $sql = "SELECT threadid FROM {$tableprefix}thread WHERE importthreadid={$old_id}"; } Code:
// It's a post link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}{$old_post_script}") === 0) { $action = 'post'; // Cuts 6020 out of this /index.php/topic,603.msg6020.html#new $old_id = (substr(substr($_SERVER['REQUEST_URI'], intval(strpos(substr($_SERVER['REQUEST_URI'], 0), '.msg')) + 4), 0, strpos(substr($_SERVER['REQUEST_URI'], intval(strpos(substr($_SERVER['REQUEST_URI'], 0), '.msg')) + 4), '.'))); $sql = "SELECT postid FROM {$tableprefix}post WHERE importpostid={$old_id}"; } User Link - Tell it to grab the int value for users profile Code:
// It's a user link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}{$old_user_script}") === 0) { $action = 'user'; // Cuts 41 out of this : index.php?action=profile;u=41 $old_id = intval(substr($_SERVER['REQUEST_URI'], 28, 4)); $sql = "SELECT userid FROM {$tableprefix}user WHERE importuserid={$old_id}"; } |
#34
|
||||
|
||||
I looked over the code and it looks fine to me. There is one nuance that is not really important. When you are using intval to parse a number from a string, you don't need to snip off the number, you just need to start at the right place and intval will stop converting when it finds a non-numeric character.
While we are discussing this, I decided I needed to move the importid's into their own table and built this table: Code:
CREATE TABLE `importedid` ( `idtype` VARCHAR( 25 ) NOT NULL, `oldid` INT UNSIGNED NOT NULL, `newid` INT UNSIGNED NOT NULL, PRIMARY KEY (`idtype`, `oldid`) ) TYPE = MYISAM; Code:
INSERT INTO `importedid` (`idtype`, `oldid`, `newid`) SELECT "attach", `importattachmentid`, `attachmentid` FROM `attachment` WHERE `importattachmentid`>0 PHP Code:
The older version that takes the id's out of the various importid's in the tables works just fine. I put it back each time I try to fix the above with a new idea and the new idea does not work. |
#35
|
|||
|
|||
You need the SQL database for this to work? Do I just point it to my existing SQL database that hosts the VB or do I need to make a new line and/or database separately?
I thought that the 404.php would dynamically parse the old URL and forward to a new URL based on the parsing self contained in the 404.php document. Am I wrong? |
#36
|
||||
|
||||
Quote:
If you use the basic approach, you cannot clean up your database and remove the importid's from it. This is generally not a big deal unless you are doing multiple imports. I just wanted to clean it up by moving the importid's into a separate table. I also added some other external reference url's that had shown up in the log table. I decided that those url's for attachments, printthread requests, etc. should also be translated appropriately. I also made the url for items that are not found be a thread on my message board talking about the trap facility. |
#37
|
|||
|
|||
UPDATE: everything seems to work properly except ONE HUGE THING:
nothing after /index.php/ triggers a 404 but rather loads the forum index at whatever URL is input. All of SMF's urls come after /index.php which makes this a huge disaster. I'm not sure why this is happening. Error reporting doesn't help because the 404 is never triggered to begin with. Anyone? |
#38
|
||||
|
||||
I'm also having a similar problem. The 404.php simply redirects to the front page of the forums/index.php regardless of the link. The script doesn't seem to be seeing the URI request.
I assume it is because of the old IPB url versus the new VB url I'm using. I'm trying to forward to my current test environment. (IP and urls changed to protect the innocent.) Old IPB link: http://mysite.com/forums/index.php?showtopic=2400 should translate/forward to New VB link: http://192.168.2.1/~mysite/forums/sh...ad.php?t=47000 I assume the script is having trouble using an IP + ~home directory style link? Is that the issue? Turning on debug shows no results, so it's obviously not seeing the urls. Any ideas? Appreciate any help/info. |
#39
|
||||
|
||||
Hmm. It looks like vBulletin isn't passing on a 404 error because the old url is pointing to "index.php?showtopic=", and vBulletin will automagically display "index.php" regardless of the "?showtopic=". Is there any way to stop vBulletin from doing this so it will properly call the 404.php file?
|
#40
|
||||
|
||||
It sounds like you are not pointing to a missing file.
It is critical that the old url resolve to a different location than the new message board. In the absence of that you will not get a 404 "missing file" error. If the old message board is also vBulletin and you put the new one in the same location, you cannot get a 404 message and therefore cannot trap it. |
#41
|
||||
|
||||
I'm guessing it has to do with this IPB (Invision Power Board) issue with the 404 redirection script.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|