Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling a phalcon php MVC controller via ajax

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?

like image 442
Ori Price Avatar asked Mar 14 '15 21:03

Ori Price


1 Answers

Ok, My problem was in the rewrite mechanism as i thought. First, in httpd.conf file i had to:

  1. Change "AllowOverride None" to "AllowOverride All" in the relevant directory.
  2. My "mod_rewrite" was disabled, so i had to un-comment the line: "# LoadModule rewrite_module modules/mod_rewrite.so"
like image 149
Ori Price Avatar answered Nov 10 '22 22:11

Ori Price