Rewriting php
2 messages
• Page 1 sur 1
Consultez la formation URL Rewriting et sites dynamiques de WebRankInfo / Ranking Metrics
- modv
- WRInaute impliqué

- Messages: 551
- Inscription: 31 Oct 2007
Rewriting php
Salut à tous,
j'ai un peu de mal à mettre en place ma réécriture d'urls.
Pour aller plus vite, je met tout le fichier en question:
http://www.url.com/browse_games.php?start=2 ... et je veux http://www.url.com/jeux-2.html ; ./jeux-3.html .....
Merci,
j'ai un peu de mal à mettre en place ma réécriture d'urls.
Pour aller plus vite, je met tout le fichier en question:
http://www.url.com/browse_games.php?start=2 ... et je veux http://www.url.com/jeux-2.html ; ./jeux-3.html .....
- Code: Tout sélectionner
<?
if(isset($_GET['start']))
$start=$_GET['start'];
else {
$start=1;
$_GET['start'] = 1;
}
$cpage = $start;
$start = ($start * $ipp) - $ipp;
$where = "";
$action_url = "";
if(!isset($_GET['action'])) {
$myquery = mysql_query("SELECT * FROM {$prefix}games ORDER by gam_id DESC LIMIT $start,$ipp;") or report("fetch all games : ");
$from = "FROM {$prefix}games";
}
if(isset($_GET['action'])){
if($_GET['action'] == "featured") {
$myquery = mysql_query("SELECT * FROM {$prefix}games WHERE gam_status='F' ORDER by gam_id DESC LIMIT $start,$ipp;") or report("fetch all games : ");
$where = "WHERE gam_status='F'";
$action_url = "&action=featured";
$from = "FROM {$prefix}games";
}
if($_GET['action'] == "played") {
$myquery = mysql_query("SELECT * FROM {$prefix}games ORDER BY gam_views DESC LIMIT $start,$ipp;") or report();
$action_url = "&action=played";
$from = "FROM {$prefix}games";
}
if($_GET['action'] == "rated") {
$sql = "SELECT COUNT({$prefix}ratings.rat_id) as rates,{$prefix}ratings.rat_game_id,{$prefix}games.* as thenamefield,ROUND(AVG({$prefix}ratings.rat_num),2) as rating
FROM {$prefix}ratings, {$prefix}games WHERE {$prefix}games.gam_id = {$prefix}ratings.rat_game_id GROUP BY rat_game_id
ORDER BY rates DESC,rating DESC LIMIT $start,$ipp";
$myquery = mysql_query("$sql") or report();
$action_url = "&action=rated";
$from = "FROM {$prefix}games gm, {$prefix}ratings ra WHERE gm.gam_id=ra.rat_game_id GROUP BY gm.gam_id";
}
if($_GET['action'] == "commented") {
$myquery= mysql_query("SELECT *, COUNT(*) as total FROM {$prefix}games gm, {$prefix}comments ca WHERE gm.gam_id=ca.cmt_gam_id GROUP BY gm.gam_id ORDER BY total DESC LIMIT $start,$ipp;") or report();
$action_url = "&action=commented";
$from = "FROM {$prefix}games gm, {$prefix}comments ca WHERE gm.gam_id=ca.cmt_gam_id GROUP BY gm.gam_id";
}
}
if($ta["total"]==0) {
$list_data = "<center><b>...</b></center>";
$pagination = "";
$total_res = "";
}
else {
$pages = "";
if($ta['total'] > $ipp) {
$pages = "";
$total_pages = ceil($ta['total'] / $ipp);
$pages = pagination2($total_pages, $cpage, 8, "./browse_games.php","$action_url");
}
$fres = $myquery;
if(mysql_num_rows($fres)==0)
$list_data = "<table width=100% align=center><tr><td><b>...</b><br><br></td></tr></table>";
else {
$list_data = "<table>";
$counter = 0;
while($f_art_row=mysql_fetch_assoc($fres)) {
$gam_url = $settings['set_seo_onoff'] =='off'
? "$root_path/jeux/".plaintext($f_art_row['gam_title'])."-$f_art_row[gam_id].html"
: "$root_path/game.php?id=$f_art_row[gam_id]";
if($counter == 2) {
$list_data .= "<tr>";
}
if(strstr($f_art_row['gam_thumb_url'], "http"))
$gam_thumb = $f_art_row['gam_thumb_url'];
else
$gam_thumb = "$root_path/gam_previews/$f_art_row[gam_thumb_url]";
if(strlen($f_art_row["gam_desc"])>95) {
$f_art_row["gam_desc"] = str_cut($f_art_row["gam_desc"],95);
$f_art_row["gam_desc"] = $f_art_row["gam_desc"].'..';
}
$list_data .= "
<td>
<div id='categorie-jeux'>
<div id='c-jeux-l'><a href='$gam_url' title=\"$f_art_row[gam_title]\">
<img title=\"$f_art_row[gam_title]\" src='$gam_thumb' />
</a></div>
<div id='bloc-jeux-r'>
<div id='c-jeux-t'><a href='$gam_url' title=\"$f_art_row[gam_title]\"><strong>$f_art_row[gam_title]</strong></a></div>
<div id='c-jeux-b'>$f_art_row[gam_desc]</div>
</div>
</div>
</td>";
if($counter == 1) {
$list_data .= "</tr>";
$counter = -1;
}
$counter++;
}
$list_data .= "</table>";
}
$total_res = "...";
$pagination = "$pages";
}
mysql_close();?>
Merci,
-

fabor - WRInaute discret

- Messages: 152
- Inscription: 17 Mar 2005
Re: Rewriting php
dans ton fichier .htaccess il faut que tu mettes
Ensuite sur ton site partout où tu appeles des pages jeux tu dois mettre une url de la forme http://www.url.com/jeux-2.html
- Code: Tout sélectionner
Options +FollowSymlinks
RewriteEngine on RewriteRule ^jeux-([0-9]+).html$ http://www.url.com/browse_games.php?start=$1 [L]
Ensuite sur ton site partout où tu appeles des pages jeux tu dois mettre une url de la forme http://www.url.com/jeux-2.html
2 messages
• Page 1 sur 1
Formation recommandée sur ce thème :
Formation URL Rewriting et sites dynamiques : apprenez comment mettre en place la réécriture d'URL, comment optimiser vos URL et profiter de vos pages dynamiques pour booster votre référencement. Formation animée par Olivier Duffez et Fabien Facériès, experts en référencement naturel.
Tous les détails sur le site Ranking Metrics : programme, prix, dates et lieux, inscription en ligne.
Lectures recommandées sur ce thème :
Qui est en ligne
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités
