【问题标题】:Domain masking across different servers with Htaccess使用 Htaccess 跨不同服务器进行域屏蔽
【发布时间】:2015-04-08 16:22:23
【问题描述】:

我在 domain1.com/blog 上安装了 Wordpress,但理想情况下我希望它显示为 sub.domain2.com/blog

这些域位于不同的服务器上。理想情况下,我会将 WP 安装在与 domain2 相同的服务器上,但现在不可能。

我已经能够让 sub.domain2.com/blog 显示 WP 主页,但是 htaccess 和 apache 是否可以重写 domain1.com 上的 url 以显示为 sub.domain2.com?

除了简单的 url 重写之外,我对 htaccess 的经验有限,但出于安全原因,我怀疑这是不可能的。

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    您当然可以将domain1.com 上的请求重定向到sub.domain2.com

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(blog/.*)$ http://sub.domain2.com/$1 [R=301,L]
    

    将上述内容放在domain1.com 的htaccess 文件中。

    【讨论】:

      猜你喜欢
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 2020-05-08
      • 2019-09-20
      • 2012-01-27
      • 2016-07-21
      • 2014-08-05
      • 2013-07-21
      相关资源
      最近更新 更多