Welcome Guest, Not a member yet? Register   Sign In
Proper way yo deal with uri segments?
#1

(This post was last modified: 10-11-2021, 09:35 PM by dgvirtual.)

I have my development environment at the web server root (accessible through http://localhost:8080/), but my production installation is in a subdirectory of the web server root (https://site.lt/my_subdir/).

For some reason, the uri helper on the production environment returns the subdirectory name as the first element in the segment array. So I have to use funny workarounds to get the same segment in both installs, see code below. I do have proper base url settings in the .env files in each environment (app.baseURL variable points to the above-mentioned addresses)...

So, my question is: is there a better way to use the CI4 uri helper? Is there a bug in the code?

PHP Code:
$uri current_url(true);
if (
$uri->getSegment(1) == 'my_subdir'$sgm 5//bug in uri?
else $sgm 4;
if (
$uri->getSegment($sgm) == 'pdf'$variant 'pdf';
else 
$variant 'regular'
==

Donatas G.
Reply


Messages In This Thread
Proper way yo deal with uri segments? - by dgvirtual - 10-11-2021, 01:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB