I'm developing a PHP script which uses REST API. The request from client goes to
http://.../api/cart
I have a directory api/cart/ and a script index.php in it.
When client tries to request http://.../api/cart
server redirects it to http://.../api/cart/
(which is right, by the way) but it returns 300 response. But i need him to receive "200 OK"
What should I do? Maybe write some specific .htaccess?
This is a mod_negotiation thing, it depends on what other kind of stuff you have in your directories. Here, mod_negotiation sees a couple of things that the /api/cart
request can map to, and it lets the user-agent know. You could try messing with multiviews and/or the mod_dir (to prevent the redirect). So maybe something like this in the /api/
directory:
Options -Multiviews
DirectorySlash Off
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*[^/])$ /api/$1/ [L]