Index
Forums
Annuaire
Référencement
Télécharger
  phpBB SEO : Référencement Google, MSN, Yahoo, Annuaires, Forums  
phpBB SEO
Boards
Directory  
SEO  
Downloads
 
  Rechercher Search
    S'enregistrer
Pseudo :  Passe :  Auto  
Register  
 
   
Aide sur sitemap pour mod_rewrite avancé

 
Poster un nouveau sujet   Répondre au sujet    phpBB SEO » Forum Référencement  » mod Rewrite phpBB3  » Réécriture URL Avancée
::  
Auteur Message
manulesurfeur



Inscrit le: 25 Juin 2008
Messages: 1

Aide sur sitemap pour mod_rewrite avancéPosté le: Jeu Juin 26, 2008 7:01 am    Sujet du message: Aide sur sitemap pour mod_rewrite avancé

Bonjour à tous.

En attendant la sortie de GYM, j'ai essayé de battailler un peu avec du code trouvé sur le net pour offrir a mon forum phpbb3 des sitemaps.

Avec un fragment de code trouvé sur le net, un poil corrigé, j'obtient des sitemaps...
Je pense que le code doit marcher uniquement pour de la réecriture basique avec le mod_rewrite phpbbseo, ou pas trop optionnée avec la réecriture avancée.
Moi j'ai activé pas mal d'options genre mots clefs pour les forum etc, et du coup les urls générés sont incorrectes.

De plus, deux lignes dans le .htaccess servent à ré-ecrire l'url d'interrogation des sitemap virtuels des forums, ce qui est incompatible avec la réecriture avancé il me semble.

Quelqu'un a des idées?

Merci

sitemap.php

Code:
<?php
//  ==========================================================================
//  phpBB Google Sitemap Generator v1.0.0
//  http://www.gotaxe.com/phpbb-sitemap.php
//  ==========================================================================
//  Script created by John Brookes
//  Copyright John Brookes ?2005
//  http://www.gotaxe.com
//  ==========================================================================
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//  ==========================================================================

// Some configuration options!

define('FORUM_DOMAIN_ROOT', 'http://www.example.com/forum/'); // Full URL with trailing slash!
define('FORUM_URL_SUFFIX', ''); // What comes up after the forum ID?
define('THREAD_URL_SUFFIX', '.html'); // What comes up after the thread ID?

$disallow = array('Forum_a_pas_prendre_en_compte'); // Forum names that are disallowed or always empty

// --------------------------------------------------
// You don't need to edit anything below this line!!!
// --------------------------------------------------

define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'config.'.$phpEx);

if ($_GET['fid']) { $fid = $_GET['fid']; }

// Sitemap File    <sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">
// URL Index File  <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">';
if (isset($fid)) {
  echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
  if ($fid == '65535') {
    // Let's first send out the header & homepage
    echo '  <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">'."\n";
    echo '    <url>
      <loc>'.FORUM_DOMAIN_ROOT.'</loc>
      <changefreq>daily</changefreq>
    </url>';
    // Let's send out a URL list of forums
    $sql = 'SELECT forum_id,forum_name FROM '.$table_prefix.'forums;// WHERE auth_view = "0" and auth_read = "0"';
    $result = $db->sql_query($sql);
    while ($data = $db->sql_fetchrow($result)) {
         if (!array_search($data['forum_name'], $disallow)) {
         
      echo '
         <url>
      <loc>'.FORUM_DOMAIN_ROOT. $phpbb_seo->set_url($data['forum_name'], $data['forum_id'], $phpbb_seo->seo_static['forum']).'</loc>
      <changefreq>daily</changefreq>
         </url>';
         }
      }
    echo '  </urlset>';
      $db->sql_freeresult($result);
  } else {
    // Let's check it's not a restricted forum
    $sql = 'SELECT forum_id FROM '.$table_prefix.'forums WHERE forum_id = "'.$fid.'"';
      $result = $db->sql_query($sql);
    $data = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);
    if ($data['forum_id'] == $fid) {
      echo '  <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">'."\n";
$sql = 'SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
         FROM '.$table_prefix.'topics t, '.$table_prefix.'users u, '.$table_prefix.'posts p, '.$table_prefix.'posts p2, '.$table_prefix.'users u2, '.$table_prefix.'forums f
         WHERE t.forum_id = f.forum_id and t.forum_id = '.$fid.' AND t.topic_poster = u.user_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id ORDER BY t.topic_type DESC, t.topic_last_post_id DESC';
         $result = $db->sql_query($sql);
      while ($data = $db->sql_fetchrow($result)) {
        echo '    <url>
            <loc>'. FORUM_DOMAIN_ROOT . $phpbb_seo->set_url($data['forum_name'], $data['forum_id'], $phpbb_seo->seo_static['forum']) . "/" . $phpbb_seo->format_url(censor_text($data['topic_title'])). '-t' . $data['topic_id'] . THREAD_URL_SUFFIX .'</loc>
            <lastmod>'.date('Y-m-d', $data['post_time']),'</lastmod>
            </url>';
       
      }
     echo '  </urlset>';
      $db->sql_freeresult($result);

    }
  }
} else {
  echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
  echo '  <sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">'."\n";
    // Let's create a link to the main forum index sitemap
  echo '    <sitemap>
      <loc>'.FORUM_DOMAIN_ROOT.'forum-65535.xml</loc>
   </sitemap>';
    // Let's do a loop here and list all the forums!
    $sql = 'SELECT forum_id,forum_name FROM '.$table_prefix.'forums';// WHERE auth_view = "0" and auth_read = "0"';
    $result = $db->sql_query($sql);
    while ($data = $db->sql_fetchrow($result)) {
         if (!array_search($data['forum_name'], $disallow)) {
      echo '
            <sitemap>
            <loc>'.FORUM_DOMAIN_ROOT. $phpbb_seo->set_url($data['forum_name'], $data['forum_id'], $phpbb_seo->seo_static['forum']) .'-'.$data['forum_id'].'.xml</loc>
            </sitemap>';
         }
    }
  echo "\n".'  </sitemapindex>';
   $db->sql_freeresult($result);

}

?>


Rajout .htaccess


Code:

RewriteRule ^sitemap.xml$ sitemap.php [L]
# conseillé de base dans le code trouvé
#RewriteRule ^forum/[a-z0-9_-]*-([0-9]+).xml$ /forum/sitemap.php?fid=$1 [L]
# le mien dans les essais avec mon forum
RewriteRule ^forum/[a-z0-9_-]*-f([0-9]+).xml$ /forum/sitemap.php?fid=$1 [L]
Revenir en haut de page
Montrer les messages depuis:   
Poster un nouveau sujet   Répondre au sujet    phpBB SEO » Forum Référencement  » mod Rewrite phpBB3  » Réécriture URL Avancée
Page 1 sur 1

Navigation Autres sujets de discussion

Sauter vers: