0

I'm testing my api. It success on GET and POST method. But another method such as PUT/DELETE/PATCH, the apache server reponse a 301 redirect pernamently to the same url use GET method.
This is my .htaccess file content is:

   RewriteEngine on
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^ index.php [L]
   RewriteRule !^(public/|index\.php) [NC,F]

This is log content for a respone:

::1 - - [13/Mar/2020:01:09:22 +0700] "LINK /mvc HTTP/1.1" 301 328 "-" "PostmanRuntime/7.23.0"
::1 - - [13/Mar/2020:01:09:22 +0700] "GET /mvc/ HTTP/1.1" 200 3 "http://localhost/mvc" "PostmanRuntime/7.23.0" 

Please help and explain the problem of my .htaccess. Thanks for all.

huy tran tan
  • 23
  • 1
  • 5
  • Does this answer your question? [How to enable and use HTTP PUT and DELETE with Apache2 and PHP?](https://stackoverflow.com/questions/2934554/how-to-enable-and-use-http-put-and-delete-with-apache2-and-php) – rx2347 Mar 13 '20 at 03:50
  • On a normal server without configuring anything, it works exactly for all http method, but when I configure .htaccess, it redirect all the method to GET. – huy tran tan Mar 13 '20 at 04:41
  • Not sure what this could have to do with the rewriting you have shown. This actually looks more like a “add trailing slash” redirect? Is `/mvc` a physically existing directory? https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryslash – CBroe Mar 13 '20 at 07:51
  • mvc/ is the directory I place my api in development on local, – huy tran tan Mar 13 '20 at 08:48
  • I dont know why the server respone 301 for all the method except GET an POST and redirect to GET – huy tran tan Mar 13 '20 at 08:54

0 Answers0