Create a file called . htaccess and paste the following code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Next save this file to the root of your site, very important, if you are doing your site on localhost have to activate the mod_rewrite of Apache
Second step is to manipulate the URL passed in . htaccess
PHP
if(isset($_GET['url'])){
$url = $_GET['url'];//pega o valor da url
$open_url = explode('/', $url);//separa a URL depois de cada barra (exemplo: www.meusite.com/artigo/novidades
}
if(isset($open_url[0])){
$arquivo = $open_url[0];//dá um print_r($open_url) que você vai entender
}elseif(isset($open_url[1])){
$post = $open_url[1];
}
Here you do the checks of the pages allowed
$diretorio = "pasta";//nome do diretório onde as páginas tem que estar
$paginas = array('pagina1','pagina2');
if(isset($arquivo) && in_array($arquivo, $paginas)){
include_once("$diretorio/$arquivo.php");
}else{
include_once("$diretorio/home.php");
}
I’m sorry if you got confused,I answered from the phone, there’s a very basic system of URL AMIGAVEL
Hello @Bruno I think these questions can help you How can I simplify Urls for a website?, User-friendly URL with Nginx
– Icaro Martins
User friendly url search and htaccess, this solves.
– Yure Pereira
Your question is very broad, but try reading this article, it may help http://blog.thiagobelem.net/learning-friendlyurlss
– Wictor Chaves