Wordpress API returns 404 on OSX(永久链接已启用)

Wordpress API returns 404 on OSX (permalinks are enabled)

我已经安装了 rest-api 2.0beta9 module of wordpress 4.4 on El Capitan OSX 10.11.2

我已将 /etc/apache2/httpd.conf 更改为 运行 作为我的用户,以便它可以轻松更新 Sites 文件:

User jtosey
Group staff

我还在用户配置中启用了 AllowOverride All

$ cat /etc/apache2/users/jtosey.conf 
<Directory "/Users/jtosey/Sites/">
    AddLanguage en .en
    LanguagePriority en fr de
    ForceLanguagePriority Fallback
    Options Indexes MultiViews
    # required for REST API:
    AllowOverride All
    Order allow,deny
    Allow from localhost
    Require all granted
</Directory>

并且我更改了永久链接,这导致创建了 .htaccess

$ cat /Users/jtosey/Sites/wordpress/.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~jtosey/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~jtosey/wordpress/index.php [L]
</IfModule>

我可以轻松卷曲主页:

$ curl http://localhost/~jtosey/wordpress/

<!DOCTYPE html>
<html lang="en-CA" class="no-js">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="profile" href="http://gmpg.org/xfn/11">
    <script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>
<title>AAA &#8211; Car Culture</title>

但我在 API:

上得到了 404
$ curl http://localhost/~jtosey/wordpress/wp-json/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /~jtosey/wordpress/wp-json/ was not found on this server.</p>
</body></html>

有什么想法吗?

我终于明白了。我在 Apache 配置中遗漏了一行。如果您遇到类似的问题,除了安装 Wordpress REST 插件并启用它之外,这些是我为使其正常工作所做的确切配置更改:

$ diff /etc/apache2/httpd.conf /etc/apache2/httpd.conf~orig
166c166
< LoadModule userdir_module libexec/apache2/mod_userdir.so
---
> #LoadModule userdir_module libexec/apache2/mod_userdir.so
168,169c168,169
< LoadModule rewrite_module libexec/apache2/mod_rewrite.so
< LoadModule php5_module libexec/apache2/libphp5.so
---
> #LoadModule rewrite_module libexec/apache2/mod_rewrite.so
> #LoadModule php5_module libexec/apache2/libphp5.so
181,183c181,182
< 
< User jtosey
< Group staff
---
> User _www
> Group _www
259c258
<     AllowOverride All
---
>     AllowOverride None
494c493
< Include /private/etc/apache2/extra/httpd-userdir.conf
---
> #Include /private/etc/apache2/extra/httpd-userdir.conf
542,554d540
< # from brew install phpmyadmin
< Alias /phpmyadmin /usr/local/share/phpmyadmin
< <Directory /usr/local/share/phpmyadmin/>
<   Options Indexes FollowSymLinks MultiViews
<   AllowOverride All
<   <IfModule mod_authz_core.c>
<     Require all granted
<   </IfModule>
<   <IfModule !mod_authz_core.c>
<     Order allow,deny
<     Allow from all
<   </IfModule>
< </Directory>

下一个:

$ cat /etc/apache2/users/jtosey.conf 
<Directory "/Users/jtosey/Sites/">
    AddLanguage en .en
    LanguagePriority en fr de
    ForceLanguagePriority Fallback
    # Wordpress - FollowSymLinks required for permalinks
    Options Indexes MultiViews FollowSymLinks
    # Wordpress API - required
    AllowOverride All
    Order allow,deny
    Allow from localhost
    Require all granted
</Directory>

最后是 phpadmin 创建的以下内容:

$ cat /Users/jtosey/Sites/wordpress/.htaccess 

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~jtosey/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~jtosey/wordpress/index.php [L]
</IfModule>

# END WordPress

别忘了:

$ sudo apachectl restart

完成后。