【问题标题】:Change hostname from the URL in the Apache Web server从 Apache Web 服务器中的 URL 更改主机名
【发布时间】:2016-01-26 14:52:35
【问题描述】:

我有一个 URL,我需要更改其主机名并保持其余参数与 Apache Web 服务器中的一样。例如 实际网址 /servereq?hname=cs_load_cs&summary=true&contractID=da588be1a59f47cf8f

要成为 URL: /servereq?hname=cs_load_cs&summary=true&contractID=da588be1a59f47cf8f

我尝试使用规则实现更改: 重写规则 ^http://actualUrl.corp.com/(.*)$ http://newUrl.corp.com/$1

但 URL 仅在 '?' 之前被解析其余的不会出现在结果中。我在 online Tester 上测试了代码。 因此,我正在寻找一种在不丢失任何参数的情况下实现这一目标的方法。

非常感谢。

【问题讨论】:

    标签: apache .htaccess mod-rewrite webserver


    【解决方案1】:

    HTTP_HOST 不是 RewriteRule 模式匹配的一部分,它是由 apache 自动添加的。

    试试:

     RewriteRule ^(.*)$ http://newUrl.corp.com/$1 [NC,L,R,QSA]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-02
      • 1970-01-01
      • 2015-01-16
      • 2018-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多