getting array of uri segments excluding subdirectory in base_url() |
I am trying to find an optimal way to get an array of segments of the uri of my application that would not include the subdirectory where my app resides, if I use such (I do in production, but not in the development env).
Previously I have used code that would check the first segment against a keyword, and if it matches (which means my base_url includes a subdirectory), the first segment gets ignored: PHP Code: $uri = current_url(true); It is cumbersome and depends on the name of the directory, which might change between projects, so I was looking for alternative. Was playing with this code: PHP Code: $uri = trim(uri_string(false),'/'); However, I wonder if there are any caveats to my new approach. Any ideas? Or maybe there is a better, codeigniter'ish, way of doing it? }
==
Donatas G. (05-02-2022, 11:59 PM)JustJohnQ Wrote: Why not use: Well, because in case the url is https://mywebsite.com/appsubdir/firstseg/secondseg it returns Code: Array while in my development environment, with url like http://localohost:8080/firstseg/secondseg (no app subdirectory) it returns Code: Array And I need a universal way, independent of the name of the app subdirectory or it's absence, to get the array: Code: Array
==
Donatas G. |
Welcome Guest, Not a member yet? Register Sign In |