【问题标题】:How to redirect a URL that has parentheses如何重定向带括号的 URL
【发布时间】:2019-07-28 13:30:34
【问题描述】:

我有如下的 URL,它们的语法中有括号()。这些 URL 将重定向到不同的链接。如何处理 URL 重定向中的括号()?

^/test1/mkt_iboxx_usd_liquid_investment_grade_(ttm_hedged)_index.pdf
^/test/mkt_iboxx_usd_liquid_high_yield_(ttm%20jpy%20hedged)_index_guide.pdf

我不知道如何处理它。我试图搜索但没有找到任何好东西。

【问题讨论】:

    标签: linux apache


    【解决方案1】:

    您需要执行以下操作才能使重定向生效:

    • 对于括号,您只需将它们转义即可。使用\( 而不是(
    • URL 不能以斜杠开头,因为 Apache 很奇怪。
    • 使用\s 而不是%20\s 是空空格的正则表达式字符。

    您的重定向将如下所示:

    RewriteEngine On
    RewriteRule ^test1/mkt_iboxx_usd_liquid_investment_grade_\(ttm_hedged\)_index.pdf http://localhost/test [R=302]
    RewriteRule ^test/mkt_iboxx_usd_liquid_high_yield_\(ttm\sjpy\shedged\)_index_guide.pdf http://localhost/test [R=302]
    

    【讨论】:

    • 感谢您抽出宝贵时间发表评论。我会尽力让你知道。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-14
    • 1970-01-01
    • 2022-11-12
    • 1970-01-01
    • 2012-08-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多