Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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
Wordpress WP REST API和;只有经过身份验证的用户才能访问REST API“;_Wordpress_Rest_Api_Authentication - Fatal编程技术网

Wordpress WP REST API和;只有经过身份验证的用户才能访问REST API“;

Wordpress WP REST API和;只有经过身份验证的用户才能访问REST API“;,wordpress,rest,api,authentication,Wordpress,Rest,Api,Authentication,我有一个wordpress: 我需要使用WP-restapi 在.htaccess中: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.ph

我有一个wordpress: 我需要使用WP-restapi

在.htaccess中:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
# END WordPress

我使用http和https进行了测试

怎么了?

解决了

我把它改成了

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

重新启动发动机
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]

HTTP_授权规则必须在其他规则之前,这是因为L标志存在,L标志意味着(最后停止处理规则),因此,如果它在原始wordpress规则之后,它将永远不会到达该规则,

我也遇到了同样的问题,并通过验证是否有其他密码保护插件修复了它。我使用了一个名为密码保护的插件,并禁用它来生成身份验证令牌

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>