add prefix to form url generated by cakephp
-
28-09-2019 - |
Question
If we deploy cakephp not on root domain, but under something like
http://domain.com/folder/app-name as the root domain for cake
When we use something like $this->Form->create('abc')
it will generate post url to http://domain.com/controller/action instead of http://domain.com/folder/app-name/controller/action
how do we configure cake for this purpose?
Solution
No, it won't. It always picks it up correctly. Are you sure this is happening? Because on all my CakePHP installations it works correctly. That's the whole point of using the Form helper and HTML helper, they'll get the path right irrespective of where you deploy it.
When you're using jquery stuff, one way to solve it is to the below code to generate URL instead of hard coding them.
<?php echo $html->url('controller' => 'foo', 'action' => 'bar'); ?>