我的主要网站是www.example.com(host1,nginx)
我的博客是blog.example.com(host2,aws lightail bitnami)。
对于SEO,我们希望https://www.example.com/blog撤消代理https://blog.example.com
我已经在host1 nginx上配置了反向代理,并在host2上配置了wp-config。 当我转到/ blog时,它可以工作,但是内部帖子链接指向404
内部链接示例-https://www.example.com/2019/01/02/post-year-in-review/
看起来它要转到主域(host1 example.com)并在那寻找帖子。
请参阅下面的配置。
under nginx /etc/nginx/conf.d/example-ssl.conf (HOST 1 NGINX)
location ^~ /blog {
proxy_pass http://HOST2_IP_ADDRESS_HERE/blog;
proxy_set_header X-Real-IP $remote_addr
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http://HOST2_IP_ADDRESS_HERE/ https://$host/;
proxy_cookie_domain HOST2_IP_ADDRESS_HERE $host;
}
wp-config.php (HOST 2 bitnami wordpress)
define('WP_SITEURL','https://www.example.com/blog');
define('WP_HOME', 'https://www.example.com/blog');