Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
404 / 301 after import redirect on import ids Details »»
404 / 301 after import redirect on import ids
Version: 1.00, by Jerry Jerry is offline
Developer Last Online: Oct 2010 Show Printable Version Email this Page

Category: Miscellaneous Hacks - Version: 3.6.9 Rating:
Released: 04-22-2008 Last Update: Never Installs: 52
Re-useable Code  
No support by the author.

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

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 08-04-2008, 06:36 PM
Jerry's Avatar
Jerry Jerry is offline
 
Join Date: Jun 2003
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by jbeam View Post
I do have a logging table. It however does not have any entries for user profiles. There are a lot of ViewTopic requests and some 404 redirects (since the old phpbb directory does not exist).
The only thing I can think is finding the web server logs to see the exact request coming in and seeing what it is trying to parse.
Reply With Quote
  #23  
Old 08-08-2008, 07:39 PM
diosrl diosrl is offline
 
Join Date: Mar 2005
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a very simple problem with this mod. Why the script needs to be run for every single link?

We have three cases:

1. accessing a bookmarked or spidered link like www.example.com/oldforum/index.php. That /oldforum/ directory no longer exists, ofcourse.

2. click on an older link when browsing the new, vbulletin forum;

3. An ordinary link like example.com/test.htm, or example.com/contact.htm.

In all cases this mod is run, and i think it's not ok. First a root .htaccess must be setup, doing a redirect of all requests from /oldforum/ to /newforum/.

THEN, in the /newforum/ you can put a second .htaccess that redirects to 404.php and starts running the script.

In that way you don't parse every single link, but just the ones you are interested in. Am I correct?

For now, the only way to do this 404.php working, is to put the .htaccess in the root folder, and parse the 404.php file every single time, even with the links with no relations to the old, erased forum.

Or, you can keep the /oldforum/ directory, and put inside a .htaccess to permanently redirect all requests to the /newforum/, where we have this 404.php file...
Reply With Quote
  #24  
Old 08-08-2008, 07:50 PM
Jerry's Avatar
Jerry Jerry is offline
 
Join Date: Jun 2003
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can set up the rest as you wish, if the link isn't found it defaults to the standard 404 file, if you want to parse the content to find if it's old forum or not before the script that's just another way of doing it, you can .htaccess and only direct old forum links to it if you want, that would lower the dB load onto the webserver.

This script is just an example and works for most, though not the only and de facto way of doing it.

The resulting 301 will update the search engines over time as it is.
Reply With Quote
  #25  
Old 08-08-2008, 08:13 PM
diosrl diosrl is offline
 
Join Date: Mar 2005
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
you can .htaccess and only direct old forum links to it if you want, that would lower the dB load onto the webserver.
YES this is exactly what I was thinking!

Anyway, it's a great feature for future impex releases! At least support for 2-3 forums like phpbb, invision, etc.
Reply With Quote
  #26  
Old 08-10-2008, 05:16 PM
tommythejoat's Avatar
tommythejoat tommythejoat is offline
 
Join Date: Apr 2008
Location: Boston
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Since I don't have ready access to the domain name server, I tried to put a .htaccess redirect on the "from" board and hoped that the vBulletin board would capture the inbound requests and redirect them.

The redirect experiment did not go well. I could not get the behavior I was looking for on either end.

This is the contents of the .htaccess file located on the bbv2 site:
Code:
# bbv2 assigns .boy .pm and .cgi to the cgi-script handler in Apache
# Trailing slash references to nawcc-mb.com/bbv2/

AddHandler cgi-script .boy .pm .cgi
DirectoryIndex bbBoard.cgi bbBoard.cgi

# vBulletin message board has a 404 redirect to map bbv2 references to vBulletin references
# The bbBoard.cgi reference will be trapped by the 404 handler on mb.nawcc.org - disable until ready

Redirect permanent /bbBoard.cgi http://mb.nawcc.org/bbv2/bbBoard.cgi
I expected this to catch the reference to bbBoard.cgi and send it to mb.nawcc.org. The top two directives were already in the .htaccess file.

I put the 404 trap handler on mb.nawcc.org and edited the .htaccess file there to read:
Code:
ErrorDocument 404 /var/www/html/404t.php

php_flag log_errors on
php_value error_log /var/www/html/php_error.log
I had already been using the php error log to debug the migration software.

I tried changing the path for 404t.php to just "/" and to nothing but the file name as well as the form shown in the code box.

References to the old board are not redirected, they just display the old board.

If I edit the reference on my browser address line to substitute the new board address, I just get a 404 error. If I directly reference mb.nawcc.org/404t.php, the debug message prints when I turn on debug. With debug off, I get a 500 error, but nothing in the php error log.

Can someone tell me how the .htaccess files should be set up? I am stuck at this point.
Reply With Quote
  #27  
Old 08-15-2008, 07:57 PM
tommythejoat's Avatar
tommythejoat tommythejoat is offline
 
Join Date: Apr 2008
Location: Boston
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have the trap handler working on the new board. If I copy a url from the old board and edit the domain to be the new board everything works as expected.

However, I still have not figured out how to get the old board to do the redirect. The directive looks so simple, but it is not working.

The contents of the .htaccess file on the old system is in the post just above this one. I have looked in httpd.conf and I can't see anything that would prevent the redirect from working.

The behavior is that references to the old message board look totally unchanged and just invoke whatever page is referenced.
Reply With Quote
  #28  
Old 08-28-2008, 10:24 AM
SeV3n SeV3n is offline
 
Join Date: Jan 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Jerry. There is an error at line 92.

Quote:
$old_thread_script = "showthread{$old_ext_type}?p=";
must be

Quote:
$old_thread_script = "showthread{$old_ext_type}?t=";
Reply With Quote
  #29  
Old 08-28-2008, 07:48 PM
tommythejoat's Avatar
tommythejoat tommythejoat is offline
 
Join Date: Apr 2008
Location: Boston
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just a follow up to close my problem discussion.

The .htaccess file needed to be in the web root directory in order to redirect traffic. I was confused because the old message board software had an .htaccess in the top of the message board directory (one below the root) that was catching references and doing a cgi handler.

In any case it is working fine now. Attempts to reference the old board get redirected to the new board (different site) where the trap handler interprets them and delivers the correct thread or forum.

We had this board installed on May 22nd and will be finally going live on Sep 3rd.
Reply With Quote
  #30  
Old 09-08-2008, 10:04 PM
trigatch4 trigatch4 is offline
 
Join Date: Feb 2007
Posts: 90
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could somebody help me for modifying the script for SMF 1.1.5? I'm using "search engine friendly URLs" so they should be pretty easy to parse for someone who knows what they are doing (I clearly don't)

Forums look like this:
http://mysite.com/index.php?board=5.0

Threads look like this:
http://mysite.com/index.php/topic,775.0.html

Posts look like this:
http://mysite.com/index.php/topic,54...2.html#msg3252

In addition, I'm not fully sure how to RUN/OPERATE this? There is a 404.php and it tells you to add a line in your new forum/db but how do you execute/initiate everything?

Thanks in advance for your help!
Reply With Quote
  #31  
Old 09-08-2008, 10:38 PM
tommythejoat's Avatar
tommythejoat tommythejoat is offline
 
Join Date: Apr 2008
Location: Boston
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have been working on this for a different source system than yours, but I may be able to offer a couple of tips.

1. You need to be able to parse off the old id code for anything you want to serve on redirect.

Your forum and thread links appear to be exactly the same and neither has an identifier, so I don't think those will do you any good. Perhaps you copied the wrong thing.

2. The 404 trap program needs to find the code from the old reference that was translated to an equivalent code in the vBulletin system.

In your case this looks like either the numeric part of the topic .html file name or the message number in that file. In either case if you can find a unique string that ALWAYS preceded the critical identifier, you can use the php intval function to return that number as show in the examples in Jerry's 404 program.

The number or numbers you get by this technique need to be the ones that ImpEx previously deposited in the ImportID column of the Thread, Forum or Post table.

When you have these numbers you can use them in mySQL queries to find out what the equivalent number is in vBulletin.

If you have never done any programming in PHP or any other language, you probably have little chance of accomplishing any of this. If you have had some basic programming experience, you should be able to follow it with a fair bit of work.

Once the 404.php program is built to do the translation trick, you need to use .htaccess to call the program when your web site would have reported a 404 File not Found error. The .htaccess file needs to be in the directory that is trying to display the missing file.

Quote:
ErrorDocument 404 /trap404.php

php_flag log_errors on
php_value error_log /var/www/html/php_error.log
This is the file I am using. I found it convenient to turn on php error reporting as well as using the ErrorDocument directive to turn on the trap.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:10 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06786 seconds
  • Memory Usage 2,320KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete