【问题标题】:apache RedirectMatch that appends a querystring附加查询字符串的apache RedirectMatch
【发布时间】:2012-08-06 05:09:34
【问题描述】:

我正在尝试在 Apache 中设置添加查询字符串的重定向。我不认为我想使用 RewriteRule 因为目标是不同的网络服务器。我现在有这样的东西:

<VirtualHost 127.0.0.5:4039>
    ServerName localhost.redirect
    RedirectMatch (.*) http://otherserver.com$1?originalHost=127.0.0.5
</VirtualHost>

这适用于对@987654321@ 的请求被重定向到@987654322@。问题是@987654323@ 也被重定向到@987654324@,我想要@987654325@ 之类的东西,其中保留了原始查询字符串。

关于如何做到这一点的任何提示?我在 WAMP 上运行,并且不擅长这个 apache。

这里有一个相关问题,有人有重定向,其中目标包含查询字符串:Apache: Redirect domain to other domain with appended querystring。他们并没有尝试附加查询字符串,只是设置一个。

【问题讨论】:

    标签: apache wamp


    【解决方案1】:

    您可能不得不硬着头皮使用 mod_rewrite。它有一个用于将现有查询字符串附加到目标查询字符串的标志。您将 RedirectMatch 替换为:

    RewriteEngine On
    RewriteRule ^(.*)$ http://otherserver.com$1?originalHost=127.0.0.5 [L,QSA,R=302]
    

    它看起来几乎一样,它会用 302 重定向(如果你希望它是永久的,你可以用 301 替换),除此之外,现有的查询字符串将被整齐地附加到 @ 987654323@.

    【讨论】:

      猜你喜欢
      • 2021-05-15
      • 1970-01-01
      • 2012-09-21
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2013-01-09
      • 1970-01-01
      相关资源
      最近更新 更多