我已经在Wordpress网站上建立了一个Ember前端。这两个托管在不同的域上,因此当用户点击"查看页面"在Wordpress仪表板中,它们被发送到API站点上的页面而不是站点的前端。
我创建了与Wordpress网站匹配的路由,所以我想简单地将所有内容从API重定向到Ember网站,但仪表板和API端点除外。如果出于某种原因,有人在浏览器中直接导航到API,这也很有用。
所以我想要以下内容:
example-api.com/abc ~> example.com/abc
example-api.com/abc/def ~> example.com/abc/def
example-api.com/wp-admin ~> work as normal
example-api.com/wp-json ~> work as normal
到目前为止,我已尝试过以下内容:
RewriteEngine On
RewriteBase /
RewriteRule ^!(wp-json|wp-admin)($|/) http://example.com/$1 [R=301,L]
# 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]
</IfModule>
# END WordPress
但这似乎重定向一切。
下一步:
RewriteEngine On
RewriteBase /
RewriteRule ^(wp-json|wp-admin)($|/) /index.php [L]
RewriteRule ^index\.php$ - [L]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
# 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]
</IfModule>
# END WordPress
因为我认为它会像往常一样将请求转发给wp-json和wp-admin到index.php ......但它仍然重定向并且我收到错误&#34;请求的URL /index.php在此服务器上找不到。&#34;
非常感谢任何帮助。 TA