Announcement

Collapse
No announcement yet.

code for .htaccess to redirect vb3 vbseo URLs to vb5

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • code for .htaccess to redirect vb3 vbseo URLs to vb5

    I recently upgraded a vb3 vbseo forum to a vb5 one.

    Is there a code rewrite or addition that will make it so that the vbseo urls from the old vb3 forum redirect to the new vb5 urls? May this be done in a way that does not conflict with whatever redirect rules are already in the vb5 .htaccess?

    Here are a couple of examples:

    vbseo old url
    http://www.modeeworld.com/forums/eba...-delivery.html

    new vb5 url
    http://www.modeeworld.com/forums/for...-fast-delivery

    vbseo old url
    http://www.modeeworld.com/forums/int...st-letter.html

    vb5 new url
    http://www.modeeworld.com/forums/for...-desist-letter

    Can this be done? Thanks! Modee

  • #2
    i have written a php script (quick and dirty) that is doing that. Only some rewrites will not help. You must do it by code because nodeids and post ids have changed. The good news is that the old ids are still in the SQL Tables, so you can look at the old id and make a redirect to the new id.

    Snipplet:

    PHP Code:

    // is redirect in cache ???
    if (isset($_SERVER['REDIRECT_URL'])){
      
    $r_url=mysqli_real_escape_string($db_connect,$_SERVER['REDIRECT_URL']);
      
    $cac=mysqli_query($db_connect,"SELECT * from redirect where url='$r_url'");
      if (
    mysqli_num_rows($cac)>0){
         
    $row=mysqli_fetch_assoc($cac);
         
    $nlink=  $row['new_url'];
        
    $lfd=$row['lfd'];
        
    $counter=$row['counter'] + 1;
        
    mysqli_query($db_connect,"update redirect set counter='$counter' where lfd='$lfd'")  ;
        
    header("HTTP/1.1 301 Moved Permanently");
        
    header("Location:".$nlink);
        
    header("Connection: close");
         die();
      }




    // do redirect for new url
    @mysqli_query($db_connect,"insert into redirect set url='$r_url', wann = now(), new_url='$nlink', referer='$referer'");
    header("HTTP/1.1 301 Moved Permanently");
    header("Location:".$nlink);
    header("Connection: close"); 

    After that i write the new URL and the old url to a table to cache. For my forum now i have 375319 redirects - this can not done by some rewrite rules. So i think you can only go that way.








    Comment


    • #3
      The script you wrote above is working to redirect all your vb3 vbseo URLs to the new URLs in vb5? Where exactly are you adding the php script in? I'm not a programmer so I'm lost at what exactly to do. Thanks!

      Comment


      • #4
        The code above is only some snippets from the whole script. But yes, it redirects all (mostly) the old vbseo urls to my vb5.

        Well, to use such a script, you must know what you do. Have you already updated? Is your "old" vb3 still running? Have you a testing server?
        Last edited by AScherff; Sun 5th Apr '15, 3:20am.

        Comment


        • #5
          Yes I did a password protected vb5 test directory for a while, and after doing all the testing and so on, I went for the actual upgrade. The password protected t]vb5 test directory is still live. The old vb3 is intact in a different directory now but it is not "live." I could make it live I suppose.

          Comment


          • #6
            So, if your VB5 is live then there would be an open-heart surgery. Better to develop the script on your VB5 Testsite.

            Well, i can explain what you must do, but it will be on your own risk.

            First you need a hook. I did in index.php. Befor first line of code i include my script.:

            PHP Code:
            include_once 'redirect.php';
            if (!
            defined('VB_ENTRY'))
            {
                
            define('VB_ENTRY'1);


            You need a Table:

            PHP Code:
            CREATE TABLE `redirect` (
              `
            lfdbigint(20unsigned NOT NULL AUTO_INCREMENT,
              `
            wanndatetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
              `
            urlvarchar(120) DEFAULT NULL,
              `
            new_urlvarchar(120) DEFAULT NULL,
              `
            referervarchar(120) DEFAULT NULL,
              `
            counterint(10unsigned NOT NULL DEFAULT '0',
              
            PRIMARY KEY (`lfd`),
              
            UNIQUE KEY `old` (`url`),
              
            KEY `counter` (`counter`)
            ENGINE=MyISAM AUTO_INCREMENT=DEFAULT CHARSET=utf8 

            Then you can start with redirect.php in forumroot.

            Better way instead to discuss it here - send me a PN with your Mail, so i can sent you my redirect.php with some hints what to do.


            If you will see my script in action try for example:

            This is an old vbseo URL from my VB3

            http://knx-user-forum.de/knx-eib-for...s-bringen.html

            it will redirect you to:

            http://knx-user-forum.de/forum/%C3%B...en-bus-bringen







            Comment


            • #7
              PM sent.

              Comment

              Related Topics

              Collapse

              Working...
              X