0
Hello, I am running a website and starting to work with friendly Urls, with this structure I can perform the procedure normally and redeem the values.
Now I would like to create divisions in the URL, for example:
have today it works: site.com/contact and website.com/company
but wanted to create type: site.com/plans/fiber and site.com/client/registration.
The 1° example is working properly but I’m not able to apply divisions without using folders.
my structure is .htaccess
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
mine 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;
?>
In the question code, in the case of
/cliente/cadastro
, the value inurl
will becliente/cadastro
, that in the index php. is separated into$Url[0]
and$Url[1]
. Why doesn’t it work?– Woss