Hi, I tried to google what I need, but I can't find it. Here is my question : When I use Uri::current(), is there a way of taking off the public in the url? I saw that you can extend the class and modify the segment, but isn't it something easier I can do to achieve that?
Example : I would like to have www.localhost.com/blog/posts, but instead it return : www.localhost.com/public/blog/posts.
Your help would really be appreciated because I really dont want to find a cheap workaround! Thanks!
Thank you for your answers, but I heard that there were security issues when installing it in the docroot? Would extending the URI class and trying to take off the public segment be a good idea?
In the standard build all code is outside the docroot. Not really to introduce security (almost all files are classes, and not executable code), but something that can't be accessed, can't be hacked or misused. So it's more of a precaution.
I am not saying you should install it in the docroot (you shouldn't if that is possible), I'm just responding to the fact that you did, and now have an issue.
In the standard setup, with your webservers docroot pointing to /public, this issue does not exist, because as far as the webserver is concerned, there is no "public". It doesn't see it. Is sees only /index.php.
You only have this issue if you install the entire FuelPHP installation in your webservers docroot, because then all of a sudden the frameworks access point becomes /public/index.php. For which several solutions exist that do not involve changing any code.
Ok I understand, but now the folder structure is the same, the public folder is still there. I'm not sure I understand how to get the good url with URI::current(). Thanks for the explanation on public folder, but my main problem is the URI class that is not sending url I want.
The URI class creates the current URI based on your installation.
In a standard FuelPHP setup you have the following structure: /fuel /fuel/app /fuel/core /public
And in your webserver configuration, you should have a DocumentRoot that should point to /public of that installation. If your DocumentRoot points to / (i.e. the root folder in which you have installed everything), you have a non-standard setup.
And with a non-standard setup, you either remove /public by moving it's contents one folder level up (because that contents should be in the docroot), or you use rewrite rules to get rid of /public.
Both solutions work, and do not require any code changes.
This is exactly what ilNotturno already tried to explain to you.