I’m developing a site with CakePHP but I have a very basic doubt:
When I’m working on local, I use a virtual Host, then / means really the root of my project, then I can define all my links to static content like /static/content.css (i.e.). However, when I test the website I need to create a beta subdirectory, then the links should be changed to /beta/static/content.css.
Using relative paths like static/content.css isn’t a solution because this will only work in the main page, whereas on other controllers and actions the files are unreachable because the system look for them in controller/action/static/content.css.
My first solution is creating a global constant that I must redefine in every place I test my page (my local server, my remote server, the client remote server…) but I hope that CakePHP provides a way to solve this problem in a more elegant way.
Thank you for your attention and help.
This is why you should not be using static urls for anything, but instead be doing things like
echo $this->Html->css('your_file');which would point to/webroot/css/your_file.css