Suite à ce topic : http://www.webmaster-hub.com/index.php?showtopic=7667
J'ai voulu faire de même, or il n'y a juste qu'une redirection, l'url de ma page rechange après
Pouvez-vous jeter un coup d'oeil:
http://www.cool-attitude.net/index.php?cat=article&id=12681
http://www.cool-attitude.net/article-referencement.html
.htaccess
CODE
RewriteRule ^article-([a-z]+)?.html$ pages/fonction.php?nom=$1 [L]
fonction.php
CODE
<?
function code_url($string)
{
$string = strtolower($string);
$string = str_replace("( |')", "_", $string);
$accent = array('â','à','é','è','ê','î','ô','û','ç');
$sans_accent = array('a','a','e','e','e','i','o','u','c');
$string = str_replace($accent, $sans_accent, $string);
$string = eregi_replace("[^a-z0-9]","_",$string);
$string = eregi_replace("(^(_)*|(_)*$)","",$string);
return $string;
}
// connexion
$db_server = "****"; // The name of your server
$db_username = "****"; // The MySQL username
$db_password = "***"; // The MySQL password
$db_name = "****"; // The name of the database where your forums are installed
mysql_connect("$db_server","$db_username","$db_password");
mysql_select_db("$db_name");
$DB = mysql_query("SELECT title, tid FROM ibf_topics ORDER BY tid ASC");
while ($i=mysql_fetch_array($DB))
{
if (code_url($i["title"])==$_GET["nom"])
{
header("HTTP/1.1 301 Moved Permanently");
$id=$i["tid"];
header("Location:http://www.cool-attitude.net/index.php?cat=article&id=$id");
header("Connection: close");
}
}
?>
function code_url($string)
{
$string = strtolower($string);
$string = str_replace("( |')", "_", $string);
$accent = array('â','à','é','è','ê','î','ô','û','ç');
$sans_accent = array('a','a','e','e','e','i','o','u','c');
$string = str_replace($accent, $sans_accent, $string);
$string = eregi_replace("[^a-z0-9]","_",$string);
$string = eregi_replace("(^(_)*|(_)*$)","",$string);
return $string;
}
// connexion
$db_server = "****"; // The name of your server
$db_username = "****"; // The MySQL username
$db_password = "***"; // The MySQL password
$db_name = "****"; // The name of the database where your forums are installed
mysql_connect("$db_server","$db_username","$db_password");
mysql_select_db("$db_name");
$DB = mysql_query("SELECT title, tid FROM ibf_topics ORDER BY tid ASC");
while ($i=mysql_fetch_array($DB))
{
if (code_url($i["title"])==$_GET["nom"])
{
header("HTTP/1.1 301 Moved Permanently");
$id=$i["tid"];
header("Location:http://www.cool-attitude.net/index.php?cat=article&id=$id");
header("Connection: close");
}
}
?>
Merci d'avance,
Sébastien