As stated in the comments, the content of the global variable $_SERVER["REQUEST_URI"]
is the way:
Novo/adm/categoria/1-Nome_Categoria
It was also stated in the comments that the content of interest is only the part of adm
from then on, just treat this value by removing that which is not of interest. This can be done in various ways.
If the directory name is not changed over time, just removing the contents of the string is enough:
$url = str_replace("Novo/", "", $_SERVER["REQUEST_URI"]);
In this way, $url
would be adm/categoria/1-Nome_Categoria
, as desired.
If the directory name is subject to change over time, but there is always a directory, you can only remove the first snippet of the string until the first occurrence of /
:
$url = substr($_SERVER["REQUEST_URI"], strpos($_SERVER["REQUEST_URI"], '/')+1);
The result will be the same, regardless of what the directory name is, as long as there is a.
If there is a possibility that there is more than one directory, but that the URL will always start with adm
, you can search for this snippet in your URL, this way:
$url = substr($_SERVER["REQUEST_URI"], strpos($_SERVER["REQUEST_URI"], 'adm'));
The result would also be the same, regardless of the number and name of directories present in the URL.
It wouldn’t just be the value of
$_SERVER["REQUEST_URI"]
?– Woss
You’re just returning me.
Novo/adm/categoria/1-Nome_Categoria
Adm forward.– PoneiMlditoUM
You have to cut the URI
– Panda
All the URL’s that you pick up have Adm in front ? or always want to cut the first path ?
– Panda
URI is returning the correct path, however, I would like to remove from the string this New
– PoneiMlditoUM