I have the following php code to make my site urls friendly:
<?php
$atual = (isset($_GET['pg'])) ? $_GET['pg'] : 'home';
$permissao = array('home', 'contato', 'sobre', 'politica');
$pasta = 'arquivos';
if (substr_count($atual, '/') > 0){
$atual = explode('/', $atual);
$pagina = (file_exists("{$pasta}/".$atual[0].'.php') && in_array($atual[0], $permissao)) ? $atual[0] : 'erro';
} else {
$pagina = (file_exists("{$pasta}/".$atual.'.php') && in_array($atual, $permissao)) ? $atual : 'erro';
}
?>
My .htaccess looks like this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pg=$1 [L]
For static pages works perfectly. The problem now is to adapt this code to dynamic pages.
On my site I'm going to need a category.php and company.php page that will get the 'slug' value from my database.
The urls would look like this:
site.com.br/categoria.php?slug=nome-of-category
site.com.br/empresa.php?slug=company-name
How to turn these urls into:
site.com.br/nombre-da-categoria
site.com.br/company/company_name
How can I make the sql call on these pages to display the bank's values?
Can anyone help me please?