Redirect 301 automatico da phpBB a vbSeo, come?


Una soluzione veloce ad un problema che potrebbe essere comune.

Come ci segnala l’utente “dormopoco” in questa discussione del Forum GT, passando da un forum su phpBB ad un forum basato su vbSeo, si verifica un problema: gli URL già esistenti non fanno dei redirect 301 in automatico.

Come risolvere il problema in breve tempo?

Ora vi diamo una mano, condividendo direttamente i file del Forum GT e in questo post, cominciando da “Viewtopic.php“:

<?php
// block perl worm
if(stristr($QUERY_STRING,'%2527')) {die();}
// end block perl worm

include_once 'includes/functions_vbseo.php';
vbseo_get_options();
vbseo_prepare_seo_replace();
vbseo_get_forum_info();

$idtopic = $_GET['t'];
$idpost = $_GET['p'];
$start = $_GET['start'];

$hostnm = "localhost";
$usernm = "user";
$pwd = "pass";
$dbName = "nomedeldb";

if(!MYSQL_CONNECT($hostnm,$usernm,$pwd)){
	die($err[2]);
}
if (!mysql_select_db($dbName)){
	die($err[2]);
}
if($idtopic != ""){
  $getthreads =  mysql_query("SELECT * FROM VB_thread WHERE importthreadid =".$idtopic);
  $conta=0;
    while($tmp = mysql_fetch_assoc($getthreads))
    {
     $threadrow = $tmp;
     $conta++;
    } 

  if($start>=0){
    $threadurl = vbseo_thread_url_row($threadrow, $start);
  }else{
    $threadurl = vbseo_thread_url_row($threadrow);
  }

  header( "HTTP/1.1 301 Moved Permanently" );
  header("Location:  http://www.TUOSITO.it/forum/".$threadurl);
}

if($idpost != ""){
  $idpost_temp =  explode("#", $idpost);
  $idpost = $idpost_temp[0];
  $getthread = mysql_query("SELECT * FROM VB_post WHERE importpostid =".$idpost);
  $threadid = mysql_result($getthread, 0, 'threadid');
  $getposts = mysql_query("SELECT * FROM VB_post WHERE threadid =".$threadid);
  $conta = 0;
    while($tmp = mysql_fetch_assoc($getposts))
    {
      $conta++;
      if($tmp['importpostid']==$idpost){
        $num = $conta;
        $idpost_new = $tmp['postid'];
      }
    } 

  header( "HTTP/1.1 301 Moved Permanently" );
  header("Location: https://www.TUOSITO.it/forum/".$idpost_new."-post".$num.".html");
}

?>

A seguire il file “Viewforum.php“:

<?
include_once 'includes/functions_vbseo.php';
vbseo_get_options();
vbseo_prepare_seo_replace();
vbseo_get_forum_info();

$forumid = $_GET['f'];
if($forumid != ""){

$hostnm = "localhost";
$usernm = "user";
$pwd = "pass";
$dbName = "nomedb";

if(!MYSQL_CONNECT($hostnm,$usernm,$pwd)){
	die($err[2]);
}
if (!mysql_select_db($dbName)){
	die($err[2]);
}

$getforum = mysql_query("SELECT * FROM VB_forum WHERE importforumid =".$forumid);
$forumid = mysql_result($getforum, 0, 'forumid');

$forumurl = vbseo_forum_url($forumid);

header( "HTTP/1.1 301 Moved Permanently" );
header("Location: https://www.TUOSITO.it/forum/".$forumurl);
}
?>

Sostitutendo i dati di connessione e URL  con quelli del vostro sito, dovreste riuscire a risolvere il problema.

Altrimenti… chiedete soccorso sul Forum GT 🙂

Aggiornamento: l’utente non aveva phpBB, ma la soluzione resta valida per tutti quelli che hanno phpBB e passano a vbSEO 😀

Sei membro del forum? Vuoi scrivere anche tu su PROGRAMMI Blog gt
Chiedilo a @giorgiotave