繁体   English   中英

将“ URL a”重定向到“ URL b”而无需在浏览器中更改“ URL a”

[英]Redirecting “url a” to “url b” without changing “url a” in the browser

我重定向vfd.com/blog在一个WordPress站点fufu.com/vfd

我所做的是像这样配置nginx(vfd.com):

location = /blog {
    return 301 http://fufu.com/vfd;
}

然后我想重写fufu.com/vfd ),以便浏览器显示vfd.com/blog

RewriteEngine On
...

RewriteRule /vfd http://vfd.com/blog

当我通过运行vfd.com/blog进行测试时,它仍然指向fufu.com/vfd

我在这里想保留http://vfd.com/blog吗? 还是有其他选择

更新1

我试图像这样设置代理:

location = /blog {
    proxy_redirect off;
    proxy_set_header Host fufu.com;
    proxy_redirect http://fufu.com/vfd http://vfd.com/blog;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

我现在得到的是404。检查日志说它找不到“ / blog”。 如果将fufu.com/vfd中的内容提供给vfd.com/blog,为什么仍需要“ / blog”? 我在这里还想念什么?

解决了。 配置应为:

location /blog {
    proxy_pass http://fufu.com/vfd;
    proxy_set_header Host fufu.com;
    proxy_redirect http://fufu.com/vfd http://vfd.com/blog;
}

apache的.htaccess无关紧要。 现在的问题是vfd.com/blog的内容仍指向fufu.com/vfd 将对此进行进一步调查。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM