|
Pouzy
14138 messages
No-Life
Administrateur
|
Le 23 Novembre 2004 à 18h28
Bonjour
vous avez remarqué les urls de ce forum, ceci est l'effet de url rewriting pour ceux qui ne connaissent pas.
Cette méthode facilite fortement le référencement sur google bien entendu si ce dernier passe vous rendre visite.
Pour le cas de ce forum il passe régulièrement et pour preuve.
On va surveiller ce nouveau topic pour voir en combien de temps il va être référencer.
Voici le code que j'utilise sur phpBB 2.0.10
L'auteur de ce code est Twister.
Aucun bug depuis son installation.
Code #
#-----[ OUVRIR ]---------------------------------------------
#
includes/sessions.php
#
#-----[ TROUVER ]---------------------------------------------
#
$SID = 'sid=' . $session_id;
#
#-----[ REMPLACER PAR ]---------------------------------------
#
if ( est_robot() && REFERENCEMENT_BOOST ){ //if ajouté pour supprimer les sessions pour les robots
$SID = '';
}else{
$SID = 'sid=' . $session_id;
}
#
#-----[ TROUVER ]---------------------------------------------
#
function append_sid($url, $non_html_amp = false)
{
global $SID;
if ( !empty($SID) && !preg_match('#sid=#', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}
return $url;
}
Remplacer par
function append_sid($url, $non_html_amp = false) //fonction modifiée pour l'url-rewriting
{
global $SID;
if ( !empty($SID) && !preg_match('#sid=#', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}
if ( REFERENCEMENT_BOOST )
{
$url = url_rewrite( $url );
}
return $url;
}
//Fonction qui vérifie si le visiteur est un robot comme google
function est_robot() {
global $HTTP_SERVER_VARS;
$RobotsList = array (
"antibot",
"appie",
"architext",
"bjaaland",
"digout4u",
"echo",
"fast-webcrawler",
"ferret",
"googlebot",
"gulliver",
"harvest",
"htdig",
"ia_archiver",
"jeeves",
"jennybot",
"linkwalker",
"lycos",
"mercator",
"moget",
"muscatferret",
"myweb",
"netcraft",
"nomad",
"petersnews",
"scooter",
"slurp",
"unlost_web_crawler",
"voila",
"voyager",
"webbase",
"weblayers",
"wget",
"wisenutbot",
"acme.spider",
"ahoythehomepagefinder",
"alkaline",
"arachnophilia",
"aretha",
"ariadne",
"arks",
"aspider",
"atn.txt",
"atomz",
"auresys",
"backrub",
"bigbrother",
"blackwidow",
"blindekuh",
"bloodhound",
"brightnet",
"bspider",
"cactvschemistryspider",
"cassandra",
"cgireader",
"checkbot",
"churl",
"cmc",
"collective",
"combine",
"conceptbot",
"coolbot",
"core",
"cosmos",
"cruiser",
"cusco",
"cyberspyder",
"deweb",
"dienstspider",
"digger",
"diibot",
"directhit",
"dnabot",
"download_express",
"dragonbot",
"dwcp",
"e-collector",
"ebiness",
"eit",
"elfinbot",
"emacs",
"emcspider",
"esther",
"evliyacelebi",
"nzexplorer",
"fdse",
"felix",
"fetchrover",
"fido",
"finnish",
"fireball",
"fouineur",
"francoroute",
"freecrawl",
"funnelweb",
"gama",
"gazz",
"gcreep",
"getbot",
"geturl",
"golem",
"grapnel",
"griffon",
"gromit",
"hambot",
"havindex",
"hometown",
"htmlgobble",
"hyperdecontextualizer",
"iajabot",
"ibm",
"iconoclast",
"ilse",
"imagelock",
"incywincy",
"informant",
"infoseek",
"infoseeksidewinder",
"infospider",
"inspectorwww",
"intelliagent",
"irobot",
"iron33",
"israelisearch",
"javabee",
"jbot",
"jcrawler",
"jobo",
"jobot",
"joebot",
"jubii",
"jumpstation",
"katipo",
"kdd",
"kilroy",
"ko_yappo_robot",
"labelgrabber.txt",
"larbin",
"legs",
"linkidator",
"linkscan",
"lockon",
"logo_gif",
"macworm",
"magpie",
"marvin",
"mattie",
"mediafox",
"merzscope",
"meshexplorer",
"mindcrawler",
"momspider",
"monster",
"motor",
"mwdsearch",
"netcarta",
"netmechanic",
"netscoop",
"newscan-online",
"nhse",
"northstar",
"occam",
"octopus",
"openfind",
"orb_search",
"packrat",
"pageboy",
"parasite",
"patric",
"pegasus",
"perignator",
"perlcrawler",
"phantom",
"piltdownman",
"pimptrain",
"pioneer",
"pitkow",
"pjspider",
"pka",
"plumtreewebaccessor",
"poppi",
"portalb",
"puu",
"python",
"raven",
"rbse",
"resumerobot",
"rhcs",
"roadrunner",
"robbie",
"robi",
"robofox",
"robozilla",
"roverbot",
"rules",
"safetynetrobot",
"search_au",
"searchprocess",
"senrigan",
"sgscout",
"shaggy",
"shaihulud",
"sift",
"simbot",
"site-valet",
"sitegrabber",
"sitetech",
"slcrawler",
"smartspider",
"snooper",
"solbot",
"spanner",
"speedy",
"spider_monkey",
"spiderbot",
"spiderline",
"spiderman",
"spiderview",
"spry",
"ssearcher",
"suke",
"suntek",
"sven",
"tach_bw",
"tarantula",
"tarspider",
"techbot",
"templeton",
"teoma_agent1",
"titin",
"titan",
"tkwww",
"tlspider",
"ucsd",
"udmsearch",
"urlck",
"valkyrie",
"victoria",
"visionsearch",
"vwbot",
"w3index",
"w3m2",
"wallpaper",
"wanderer",
"wapspider",
"webbandit",
"webcatcher",
"webcopy",
"webfetcher",
"webfoot",
"weblinker",
"webmirror",
"webmoose",
"webquest",
"webreader",
"webreaper",
"websnarf",
"webspider",
"webvac",
"webwalk",
"webwalker",
"webwatch",
"whatuseek",
"whowhere",
"wired-digital",
"wmir",
"wolp",
"wombat",
"worm",
"wwwc",
"wz101",
"xget",
"awbot",
"bobby",
"boris",
"bumblebee",
"cscrawler",
"daviesbot",
"ezresult",
"gigabot",
"gnodspider",
"internetseer",
"justview",
"linkbot",
"linkchecker",
"nederland.zoek",
"perman",
"pompos",
"psbot",
"redalert",
"shoutcast",
"slysearch",
"ultraseek",
"webcompass",
"yandex",
"robot",
"crawl"
);
$botID = strtolower( $HTTP_SERVER_VARS['HTTP_USER_AGENT'] );
for ($i = 0; $i < count( $RobotsList ); $i++)
{
if ( strstr( $botID, $RobotsList[$i] ) )
{
return true;
}
}
return false;
}
//fonction qui réécrit l'url des pages de lecture
function url_rewrite($url){
$inf_url = parse_url( html_entity_decode( $url ) );
$get_url = array();
parse_str( $inf_url['query'], $get_url );
//index.php
if ( substr_count( $inf_url['path'], "index" ) == 1 ){
//les catégories
if ( count( $get_url ) == 1 && isset( $get_url['c'] )){
return 'categorie-'.$get_url['c'].'.html';
}
}
//viewforum.php
if ( substr_count( $inf_url['path'], "viewforum" ) == 1 ){
//le numéro du forum seul
if ( count( $get_url ) == 1 && isset( $get_url['f'] )){
return 'forum-'.$get_url['f'].'.html';
}
//f, topicdays et start
if ( count( $get_url ) == 3 && isset( $get_url['f'] ) && isset( $get_url['topicdays'] ) && isset( $get_url['start'] ) ){
return 'forum-'.$get_url['f'].'-'.$get_url['topicdays'].'-'.$get_url['start'].'.html';
}
}
//viewtopic.php
if ( substr_count( $inf_url['path'], "viewtopic" ) == 1 ){
//le numéro du sujet seul
if ( count( $get_url ) == 1 && isset( $get_url['t'] )){
return 'sujet-'.$get_url['t'].'.html';
}
//le numéro du sujet seul avec p
if ( count( $get_url ) == 1 && isset( $get_url['p'] )){
return 'vsujet-'.$get_url['p'].'.html';
}
//sujet précédent ou suivant
if ( count( $get_url ) == 2 && isset( $get_url['t'] ) && isset( $get_url['view'] ) ){
if ( $get_url['view'] == 'previous' ){
return 'prec-sujet-'.$get_url['t'].'.html';
}elseif ( $get_url['view'] == 'next' ){
return 'suiv-sujet-'.$get_url['t'].'.html';
}
}
//le numéro du sujet et start
if ( count( $get_url ) == 2 && isset( $get_url['t'] ) && isset( $get_url['start'] ) ){
return 'sujet-'.$get_url['t'].'-'.$get_url['start'].'.html';
}
//le numéro du sujet et postdays et postorder et start
if ( count( $get_url ) == 4 && isset( $get_url['t'] ) && isset( $get_url['start'] ) && isset( $get_url['postdays'] ) && isset( $get_url['postorder'] ) ){
return 'sujet-'.$get_url['t'].'-'.$get_url['start'].'-'.$get_url['postdays'].'-'.$get_url['postorder'].'.html';
}
//le numéro du sujet et postdays et postorder et start et highlight
if ( count( $get_url ) == 5 && isset( $get_url['t'] ) && isset( $get_url['start'] ) && isset( $get_url['postdays'] ) && isset( $get_url['postorder'] ) && isset( $get_url['highlight'] ) ){
return 'sujet-'.$get_url['t'].'-'.$get_url['start'].'-'.$get_url['postdays'].'-'.$get_url['postorder'].'('.urlencode($get_url['highlight']).').html';
}
}
//profile.php
if ( substr_count( $inf_url['path'], "profile" ) == 1 ){
//mode=viewprofile et num du profil
if ( count( $get_url ) == 2 && isset( $get_url['mode'] ) && $get_url['mode'] == "viewprofile" && isset( $get_url['u'] ) ){
return 'profil-'.$get_url['u'].'.html';
}
}
return $url;
}
Pour activer ou desactiver url rewriting
Code
#
#-----[ OUVRIR ]---------------------------------------------
#
includes/constants.php
#
#-----[ TROUVER ]---------------------------------------------
#
// Session parameters
define('SESSION_METHOD_COOKIE', 100);
define('SESSION_METHOD_GET', 101);
#
#-----[ APRES, AJOUTER ]------------------------------------------
#
//amélioration du référencement : suppression des sessid pour les robots et url-rewriting
define('REFERENCEMENT_BOOST', true);
Si vous définissez la constante précédente à faux, remplacez le code précédent par
Code
//amélioration du référencement : suppression des sessid pour les robots et url-rewriting
define('REFERENCEMENT_BOOST',false);
Uploadez un fichier .htaccess dans la racine de votre forum, avec ce code.
Code RewriteEngine On
RewriteRule ^index\-([0-9]*)\.html$ index.php?c=$1 [L]
RewriteRule ^forum\-([0-9]*)\.html$ viewforum.php?f=$1 [L]
RewriteRule ^forum\-([0-9]*)\-([0-9]*)\-([0-9]*)\.html$ viewforum.php?f=$1&topicdays=$2&start=$3 [L]
RewriteRule ^sujet\-([0-9]*)\.html$ viewtopic.php?t=$1 [L]
RewriteRule ^sujet\-([0-9]*)\-([0-9]*)\.html$ viewtopic.php?t=$1&start=$2 [L]
RewriteRule ^sujet\-([0-9]*)\(([^()]*)\)\.html$ viewtopic.php?t=$1&highlight=$2 [L]
RewriteRule ^sujet\-([0-9]*)\-([0-9]*)\-([0-9]*)\-([a-zA-Z]*)\.html$ viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4 [L]
RewriteRule ^sujet\-([0-9]*)\-([0-9]*)\-([0-9]*)\-([a-zA-Z]*)\(([^()]*)\)\.html$ viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 [L]
RewriteRule ^vsujet\-([0-9]*)\.html$ viewtopic.php?p=$1 [L]
RewriteRule ^prec\-sujet\-([0-9]*)\.html$ viewtopic.php?t=$1&view=previous [L]
RewriteRule ^suiv\-sujet\-([0-9]*)\.html$ viewtopic.php?t=$1&view=next [L]
RewriteRule ^profil\-([0-9]*)\.html$ profile.php?mode=viewprofile&u=$1 [L]
Toujours dans la racine un fichier robots.txt
Code Disallow: /répertoire de votre forum/sutra*.html$
Disallow: /répertoire de votre forum/ptopic*.html$
Disallow: /répertoire de votre forum/ntopic*.html$
Disallow: /répertoire de votre forum/ftopic*asc*.html$
( rédigé par setdepic )
|