.htaccess for friendly URL [duplicate]

0

How do I create Mod_Rewrite (htaccess) rules for my pages? I'm not used to .htaccess

Rules you would like to:

www.exemplo.com/index.php to www.exemplo.com

www.exemplo.com/perfil.php to www.exemplo.com/perfil

www.exemplo.com/perfil.php?p=fulano-da-silva to www.exemplo.com/perfil/fulano-da-silva

www.exemplo.com/video.php?p=fulano-da-silva&m=nome-do-video to www.exempli.com/perfil/fulano-da-silva/nome-do-video

Code:

.htaccess

RewriteEngine On
RewriteRule %{REQUEST_FILENAME} !-f
RewriteRule %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pag=$1

url.php

<?php
$atual = (isset($_GET['isw'])) ? $_GET['isw'] : 'home';
 $pasta = 'paginas';
if (substr_count($atual, '/') > 0) {
    $atual = explode('/', $atual);
    $pagina = (file_exists("{$pasta}/" . $atual[0] . '.php')) ? $atual[0] : 'erro';
    $id = $atual[1];
    $busca = @$atual[2];    

} else {    
    $pagina = (file_exists("{$pasta}/" . $atual . '.php')) ? $atual : 'erro';
    $id = 0;
    $frame=0;
}?>

index.php

<?php require_once('url.php') ?>
<?php include $pasta.'/'.$pagina.'.php'; ?>

Could someone give a light?

    
asked by anonymous 19.04.2014 / 21:34

1 answer

3

You have this material that is very good: link

You are in English but you will find a lot.

    
20.04.2014 / 03:14