The URI class parses the current request URI and gives access to those parts.
Autoloaded on Every Request
The URI class is autoloaded on every request. We can access it through the container, or via the static URI class.
Scheme
Returns “http” or “https”.
URI::scheme();
Base
Returns the host.
URI::base();
Path
Returns the path with any slash trimmed.
URI::path();
Query String
Returns the query string or NULL if there was none.
URI::query_string();
Current
Returns the current URL with or without the query string.
// With query string URI::current(); // Without query string URI::current(FALSE)
Segment
Returns the value of a specific URI segment, or FALSE if it doesn’t exist.
URI::segment(1);
Segments
Return all of the URI segments as an array.
URI::segments();
String
Returns all of the URI segments as a string, separated by slashes.
URI::string();