Reputation: 4221
i am using simple app with phalcon PHP and AngularJs. i am trying to call my phalcon PHP controller from angularJS controller through AJAX POST request.
$http.post('/ControllerName/', {params});
and i get
404 The requested URL /ControllerName/ was not found on this server
i think my request is being routed to my public folder whereas my php controller is located in Non-public folder.
these are the .htaccess rules i have
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]</IfModule>
and in the public folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]</IfModule>
what am i doing wrong?
Upvotes: 9
Views: 6744
Reputation: 4221
Ok, My problem was in the rewrite mechanism as i thought. First, in httpd.conf file i had to:
Upvotes: 4
Reputation: 92
On the assumption you are using a default and working deployment of phalcon I suggest you to check for trailing slashes, there is a manual voice about that: http://docs.phalconphp.com/en/latest/reference/routing.html anchor #dealing-with-extra-trailing-slashes
you can also test your routes with a custom script: same url before, anchor #testing-your-routes
... or.. you can put your nose into the routing system to try to find where the failure is by listening on dispatcher for dispatch:beforeDispatchLoop, there is a piece of code here http://docs.phalconphp.com/en/latest/reference/dispatching.html#inject-model-instances, you can see in the event function how the framework would guess the controller and action names:
//Possible controller class name
$controllerName = Text::camelize($dispatcher->getControllerName()) . 'Controller';
//Possible method name
$actionName = $dispatcher->getActionName() . 'Action';
... they should then exists for a successful routing, btw refer to the example code
Upvotes: 0