由于.htaccess,php curl出现301错误
当通过浏览器和邮递员访问时,我的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文件夹中由于.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文
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]