通过Ajax调用Phalcon PHP MVC控制器(calling a phalcon php MVC controller via ajax)

编程入门 行业动态 更新时间:2024-10-26 11:23:03
通过Ajax调用Phalcon PHP MVC控制器(calling a phalcon php MVC controller via ajax)

我用phalcon PHP和AngularJs使用简单的应用程序。 我想通过AJAX POST请求从angularJS控制器调用我的phalcon PHP控制器。

$http.post('/ControllerName/', {params});

我得到了

404在此服务器上找不到请求的URL / ControllerName /

我认为我的请求被路由到我的公共文件夹,而我的php控制器位于非公用文件夹。

这些是我拥有的.htaccess规则

<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule (.*) public/$1 [L]</IfModule>

并在公用文件夹中:

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]</IfModule>

我究竟做错了什么?

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?

最满意答案

好的,我的问题是在我认为的重写机制中。 首先,在httpd.conf文件中我必须:

将“AllowOverride None”更改为相关目录中的“AllowOverride All”。 我的“mod_rewrite”被禁用,所以我不得不注释该行:“#LoadModule rewrite_module modules / mod_rewrite.so”

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

Change "AllowOverride None" to "AllowOverride All" in the relevant directory. My "mod_rewrite" was disabled, so i had to un-comment the line: "# LoadModule rewrite_module modules/mod_rewrite.so"

更多推荐

本文发布于:2023-07-14 23:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1108363.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制器   PHP   MVC   Ajax   Phalcon

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!