I followed this tutorial link
Follow the code I made:
.htaccess
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
config.inc.php
<?php
define('HOME', 'http://localhost/testeAmigo/');
define('THEME','paginas');
define('INCLUDE_PATH', HOME.THEME);
define('REQUIRE_PATH',THEME);
$getUrl = strip_tags(trim(filter_input(INPUT_GET, 'url', FILTER_DEFAULT)));
$setUrl = (empty($getUrl) ? 'index' : $getUrl);
$Url = explode('/', $setUrl);
//var_dump($Url);
?>
index.php
<?php
require 'config.inc.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Teste Urls Amigáveis</title>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="?url=home"> Home</a></li>
<li><a href="?url=contato"> Contato</a></li>
<li><a href="?url=sobre"> Sobre</a></li>
</ul>
</nav>
</header>
<hr>
<!--CONTEUDO -->
<?php
$Url [1] = (empty($Url[1]) ? null : $Url[1]);
if(file_exists(REQUIRE_PATH . '/' . $Url[0] . '.php')):
require REQUIRE_PATH . '/' . $Url[0] . '.php';
elseif(file_exists(REQUIRE_PATH . '/' . $Url[0] . '/' . $Url[1] . '.php')):
require REQUIRE_PATH . '/' . $Url[0] . '/' . $Url[1] . '.php';
else:
require REQUIRE_PATH . '/404.php';
endif;
?>
<!--CONTEUDO -->
<hr>
<footer>
<center>
<label>www.teste123.com</label>
</center>
</footer>
</body>
</html>
In addition there is the folder 'pagians' which contains the files home.php, contact, php and sobre.php.