【问题标题】:Mirror a specific path to another url using .htaccess使用 .htaccess 将特定路径镜像到另一个 url
【发布时间】:2013-01-24 09:17:15
【问题描述】:

我想使用两个独立的 url,指向两个独立的网站,使用一个主机和一个后端。

到目前为止,只有一个网站(我将其命名为 domain1.com)。 并且已经使用了一些 mod 重写。

  1. 将 www.domain1.com 重定向到 domain1.com

    重写引擎开启 RewriteCond %{http_host} ^www.domain1.com$ 重写规则 ^(.*)$ http://domain1.com/$1 [R=301,L]

  2. 使用漂亮的 url,因此 domain1.com/news/item 指向 domain1.com/index.php?/news/item

    重写基础/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index.php) RewriteRule ^(.*)$ index.php?/$1 [L]

我想要实现的是以下几点

  1. domain1.com/specific_folder_name/123456789 应该指向 domain2.com/123456789 仅用于化妆品
  2. domain2.com/123456789 应该运行 /index.php?/specific_folder_name/123456789

应该是这样的:

当浏览到 domain1.com/param1/param2 时,服务器给你 index.php?/param1/param2 如果浏览到 domain1.com/specific_folder_name/123456789,您会被重定向到 domain2.com/123456789,服务器会为您提供 /index.php?/specific_folder_name/123456789

我希望这足够清楚......

【问题讨论】:

    标签: .htaccess mod-rewrite


    【解决方案1】:

    我相信您可以通过 ProxyPass Directive

    完成此操作

    该指令允许将远程服务器映射到 本地服务器;本地服务器不充当代理 常规意义上,但似乎是远程服务器的镜像。 本地服务器通常称为反向代理或网关。路径 是本地虚拟路径的名称; url 是部分 URL 远程服务器,不能包含查询字符串。

    more details

    【讨论】:

      猜你喜欢
      • 2015-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      相关资源
      最近更新 更多