【问题标题】:Redirecting "url a" to "url b" without changing "url a" in the browser将“url a”重定向到“url b”而不更改浏览器中的“url a”
【发布时间】:2015-12-03 16:30:22
【问题描述】:

我将vfd.com/blog 重定向到fufu.com/vfd 中的wordpress 网站。

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

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

然后我想重写fufu.com/vfd (apache) 以便浏览器显示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”?我在这里还缺少什么?

【问题讨论】:

  • @anubhava 这个:vfd.com/blog。也更新了问题。
  • 但是return 301 http://fufu.com/vfd不是重定向到http://fufu.com/vfd吗?我认为您可能需要使用从 vfd.comfufu.com 的代理
  • @anubhava 喜欢吗?位置 = /blog { proxy_pass fufu.com/vfd; }
  • 可能是的,但我对 nginx 了解不多
  • @anubhava 尝试了代理,现在我得到了 404。似乎有点小进步

标签: wordpress apache .htaccess nginx


【解决方案1】:

哇。解决了。配置应该是:

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 的子目录。将对此进行进一步调查。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-15
    相关资源
    最近更新 更多