Thread: Miscellaneous Hacks - 404 / 301 after import redirect on import ids
View Single Post
  #73  
Old 04-13-2010, 09:26 PM
pitrow pitrow is offline
 
Join Date: Jan 2010
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, here's what I did. Keep in mind it may not work for you, depending on your setup.

I was upgrading from phpbb 3.0.3 to vB CMS 4.0.

the old forum was on www.mydomain.com/forum.

The new CMS was installed in the root.

Most of the code works just fine, but here's exactly what I changed from the default 404.php you can download off of this page (as of today anyway).

change
Code:
$old_folder 	= 'phpBB/';
to
Code:
$old_folder 	= 'forum/';

change
Code:
$standard_404 	= 'http://www.example.com/not_found.html';
to
Code:
$standard_404 	= 'http://www.mydomain.com/404.shtml';
this points to my existing 404 file


change
Code:
$new_domain 	= 'example';
to
Code:
$new_domain 	= 'www.mydomain.com';

change
Code:
$new_folder		= 'vBulletin/';
to
Code:
$new_folder		= '';
notice I completely removed that string since I'm installing in the root.


changed the user, password and database variables to my particular values.


Inside
Code:
switch ($old_system)
{
	case 'phpBB2' :
change
Code:
$old_thread_script 	= "viewtopic{$old_ext_type}?t=";
to
Code:
$old_thread_script 	= "viewtopic{$old_ext_type}?f=";

inside
Code:
// It's for the old forum
if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}") === 0)
{
	switch ($old_system)
	{
		case 'phpBB2' :
find
Code:
$old_id = intval(substr(substr($_SERVER['REQUEST_URI'], 2), 0,  strpos(substr($_SERVER['REQUEST_URI'], 2), '&')));
now, I wasn't quite sure exactly what Jerry was doing with this code, so I just rewrote it so I'd know it would work. His might work just fine, but I didn't try it.


replace that line with:
Code:
$topic_loc = strpos($_SERVER['REQUEST_URI'],"&t=");
$end_loc = strpos($_SERVER['REQUEST_URI'],"&",$topic_loc+1);
if ($end_loc === FALSE)
{
	$old_id = substr($_SERVER['REQUEST_URI'],$topic_loc+3);
}
else
{
	$old_id = substr($_SERVER['REQUEST_URI'],$topic_loc+3, ($end_loc-($topic_loc+3)));
}

That's it.

I uploaded that to the root of my account, and made a .htaccess file with this line in it:
Code:
ErrorDocument 404 /404.php
I also deleted everything from the "forum" directory and uploaded an index.php file there that contains this:
Code:
<?PHP
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.mydomain.com/forum.php" );
?>
That way if someone tries to go to the old http://www.mydomain.com/forum, they get redirected to the new forum page, and if someone tries to get a forum or topic, the 404.php gets it and redirects them correctly.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01123 seconds
  • Memory Usage 1,781KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (16)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete