Using .htaccess for REST makes 301 redirects

I am trying to create an extremely simple RESTful test setup for the application I'm working on. I am using .htaccess to redirect URLs to my script controller, where I will parse the URLs to handle the logic.

I have a redirect job, but the problem is that if I do POST / PUT / DELETE, Firebug correctly shows my requests to the test station, but I get a 301 redirect response and then a second GET response.

How can I use htaccess to redirect url without sending 301 to browser?

This is the .htaccess I'm using now:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
+3
source share
1 answer

- :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

, (, CSS). , 301.

, PHP script 301.

+4

Source: https://habr.com/ru/post/1708614/


All Articles