Reputation: 870
Ok let me explain what problem i am having,
i had create MVC like structure in php to create web API, and using angular as front. now i have create one login page and on button click event $http.post("user/login")
get executed and in console i am getting output like this.
it is outputting whole index.php content, now i want to know what i am doing wrong?
this is my app.js code.
this is my .htaccess
ErrorDocument 404 p1.html
Header always set Access-Control-Allow-Origin "*"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php/$1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ p1.html [L]
Options All -Indexes
this is my user.php
<?php
class user
{
public static function login(){
echo json_encode(array("in user class model"));
}
}
?>
and this is my index.php
i am also using spl_autoload_register
and set_include_path
,
need serious help.....
Upvotes: 1
Views: 1036
Reputation: 1424
It looks like your request to /user/login
is rewritten to /index.php/user/login
due to the rewrite rule
RewriteRule ^(.+)$ index.php/$1 [QSA,L]
That's why you just get the response from index.php
. You'll need your rewrite rule to ignore a specific path that handles your API requests - usually you'd use a common prefix like /api
for this, for example you could use /api/user/login
.
For more details on how to achieve this see the intro to mod_rewrite.
Upvotes: 1