首页 > 解决方案 > Wordpress:301 从本地主机重定向到域名

问题描述

我将我的 Wordpress 服务器和 node.js 服务器放在同一个 AWS EC2 实例中。当 node.js 服务器在http://localhost/wp-json/wp/v2/posts使用 REST API 调用 Wordpress 服务器时,请求被 301 重定向到 EC2 实例的域名,例如https://example .com/wp-json/wp/v2/posts

这是 Apache 配置问题还是 EC2 设置问题?

curl -v http://127.0.0.1/wp-json/wp/v2/posts/
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET /wp-json/wp/v2/posts/ HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.45.0
> Accept: /
> 
< HTTP/1.1 301 Moved Permanently
< Date: Sun, 03 Nov 2019 05:22:33 GMT
< Server: Apache
< X-Powered-By: PHP/7.3.6
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< X-Redirect-By: WordPress
< Set-Cookie: PHPSESSID=solm9p823bieif699g4ggtqub6; path=/
< X-Frame-Options: SAMEORIGIN
< Location: http://example.com/wp-json/wp/v2/posts/
< Referrer-Policy: no-referrer-when-downgrade
< Access-Control-Allow-Origin: *
< Cache-Control: s-maxage=10
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
< 
* Connection #0 to host 127.0.0.1 left intact

标签: wordpressapache.htaccessredirectamazon-ec2

解决方案


推荐阅读