Hello, I'm creating a website and starting to work with friendly URls, with this structure I can perform the procedure normally and retrieve the values.
Now I would like to create divisions in the URL, for example:
I have today that works: site.com/contact and site.com/company
but wanted to create type: site.com/planos/fibra and site.com/cliente/cadastro.
The 1st example is working correctly because I am not able to apply partitions without using folders.
My structure is .htaccess
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
My index.php
<?php
$getUrl = strip_tags(trim(filter_input(INPUT_GET, 'url', FILTER_DEFAULT)));
$setUrl =(empty($getUrl)) ? 'index' : $getUrl;
$Url = explode('/', $setUrl);
$Url[0] = (!empty($Url[0]) ? $Url[0] : null);
$Url[1] = (!empty($Url[1]) ? $Url[1] : null);
$Url[2] = (!empty($Url[2]) ? $Url[2] : null);
if (file_exists(REQUIRE_PATH_INC . $Url[0] . '.php')):
require REQUIRE_PATH_INC . $Url[0] . '.php';
elseif (file_exists(REQUIRE_PATH_INC . $Url[0] . '/' . $Url[1] . '.php')):
require REQUIRE_PATH_INC . $Url[0] . '/' . $Url[1] . '.php';
else:
require REQUIRE_PATH_INC . '404.php';
endif;
?>