Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Define the current relative URI.
- *
- * @return string
- */
- public function getCurrentUri()
- {
- // Get the current Request URI and remove rewrite basepath from it (= allows one to run the router in a subfolder)
- $basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)).'/';
- $uri = substr($_SERVER['REQUEST_URI'], strlen($basepath));
- // Don't take query params into account on the URL
- if (strstr($uri, '?')) {
- $uri = substr($uri, 0, strpos($uri, '?'));
- }
- // Remove trailing slash
- $uri = '/'.trim($uri, '/');
- return $uri;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement