Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
由于.htaccess,php curl出现301错误_Php_Curl - Fatal编程技术网

由于.htaccess,php curl出现301错误

由于.htaccess,php curl出现301错误,php,curl,Php,Curl,当通过浏览器和邮递员访问时,我的url restapi.mywebsite.com/employee有效,但当我curl php时,它返回“永久移动”错误,但当我curl restapi.mywebsite.com/employee/index.php有效或restapi.mywebsite.com/employee/index也正常时,有任何线索吗 卷曲 我不希望我的API url以php扩展和索引结尾。 在我的.htaccess中,我删除了index.php的.php,我的htaccess文

当通过浏览器和邮递员访问时,我的url restapi.mywebsite.com/employee有效,但当我curl php时,它返回“永久移动”错误,但当我curl restapi.mywebsite.com/employee/index.php有效或restapi.mywebsite.com/employee/index也正常时,有任何线索吗

卷曲

我不希望我的API url以php扩展和索引结尾。 在我的.htaccess中,我删除了index.php的.php,我的htaccess文件位于employee文件夹中

RewriteEngine on

RewriteRule ^(index|id|create|delete)$ $1.php [NC,L]

RewriteRule ^id/([0-9a-zA-Z+]+) id.php?id=$1 [NC,L]
RewriteRule ^delete/([0-9a-zA-Z+]+) delete.php?delete=$1 [NC,L]

感谢阅读

尝试并添加
curl\u setopt($ch,CURLOPT\u FOLLOWLOCATION,true)并且它应该自动跟随重定向。@Magnus Eriksson它工作正常谢谢
RewriteEngine on

RewriteRule ^(index|id|create|delete)$ $1.php [NC,L]

RewriteRule ^id/([0-9a-zA-Z+]+) id.php?id=$1 [NC,L]
RewriteRule ^delete/([0-9a-zA-Z+]+) delete.php?delete=$1 [NC,L]