Woocommerce rest api不工作401未经授权
我有wordpress 5.4.1和woocommerce 4.2以及let's encrypt的ssl证书 在使用查询字符串Woocommerce rest api不工作401未经授权,woocommerce,woocommerce-rest-api,Woocommerce,Woocommerce Rest Api,我有wordpress 5.4.1和woocommerce 4.2以及let's encrypt的ssl证书 在使用查询字符串https://www.store.com/wp-json/wc/v3/products?consumer_key=ck_XXXX&consumer_secret=cs_XXX但它突然停止工作,给了我401个未经授权的错误。我对钥匙有100%的把握 我将php与FastCgi结合使用,我了解到有时服务器无法正确读取授权,因此我尝试了以下方法 我补充说 <IfModu
https://www.store.com/wp-json/wc/v3/products?consumer_key=ck_XXXX&consumer_secret=cs_XXX
但它突然停止工作,给了我401个未经授权的错误。我对钥匙有100%的把握
我将php与FastCgi结合使用,我了解到有时服务器无法正确读取授权,因此我尝试了以下方法
我补充说
<IfModule mod_setenvif>
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>
在重新编写引擎后,返回到我的httpd.conf文件
我还安装了基本的auth插件https://github.com/WP-API/Basic-Auth
以上所有的解决方案都没有得到邮递员或失眠症的回复,同样的错误。两天后我终于得到了答案 最好的解决方案是删除所有上述内容,然后添加
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
所以我的整个访问块看起来像:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
重新启动发动机
重写基/
重写规则。*-[E=远程用户:%{HTTP:Authorization}]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
两天后我终于得到了答案
最好的解决方案是删除所有上述内容,然后添加
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
所以我的整个访问块看起来像:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
重新启动发动机
重写基/
重写规则。*-[E=远程用户:%{HTTP:Authorization}]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]