1

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.

CONSOLE ERROR it is outputting whole index.php content, now i want to know what i am doing wrong?

this is my app.js code.

APPJS

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

index i am also using spl_autoload_register and set_include_path, need serious help.....

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

so how to write my rewrite url?please help
This answer should also help: stackoverflow.com/a/8642505/1743938

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.