wordpress - 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
解决方案
推荐阅读
- javascript - jQuery 在 wordpress 的 footer.php 文件中不起作用?
- rest - Burp 如何准确扫描请求
- django - Django 和 python memcached 和会话引擎
- php - 是否可以从 gettext 过滤器访问订单元或发布元
- python - Python subprocess.Popen 不接受文本参数
- prestashop - Prestashop 添加名为“产品数量”的自定义列,显示从“ps_order”表订购的数量
- asp.net-mvc - 使用自定义路由创建 Umbraco 上下文
- c# - 将对象转换为 CSV,然后在不接触物理存储的情况下进行压缩
- c# - 如何从 .NET 运行 Progress 程序?
- graphql - 展平 Apollo GraphQL 响应(数据字段)