0
I’m doing my TCC and the theme is SEO, to complete need to put URL friendly since the current link is like this:
php post? id=79
Well, I looked into it. htaccess and managed to make the main pages (blog.php, contact.php, index.php and above me.php) friendly but those that are the posts and are retrieved from the database I can’t, would like help.
Code of . htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^contato/?$ contato.php [NC,L]
RewriteRule ^blog/?$ blog.php [NC,L]
RewriteRule ^sobremim/?$ sobremim.php [NC,L]
RewriteRule ^inicio/?$ index.php [NC,L]
</IfModule>
Programming that searches in the bank:
<?php
$mysql = new BancodeDados();
$mysql->conecta();
$ident = $_GET['id'];
//$query = mysqli_query($mysql->con,"select * from postagens where id = $ident");
$query = "SELECT * from postagens where id = $ident";
// executa a query e 'grava' o resultado em $res
$res = mysql_query($query) or die(mysql_error());
// busca os campos da query
$campo = mysql_fetch_array($res);
// armazena cada campo do banco em uma variável
$tit = $campo["titulo"];
$subt = $campo["subtitulo"];
$textinho = $campo["conteudo"];
$imge = $campo["foto"];
$categ = $campo["categoria"];
?>
<img class="card-img-top" src="admin/img/<?php echo $imge;?>">
<div class="card-body">
<h1><?php echo $tit ;?></h1>
<h2><?php echo $subt ;?></h2>
<p class="card-text"><?php echo $textinho ;?></p>
</div>
<br><br>
<hr>