【问题标题】:Redirecting urls with query strings using regex使用正则表达式重定向带有查询字符串的 url
【发布时间】:2012-07-12 19:23:55
【问题描述】:

我将网站上的旧网址重定向到不同网站上的新网址。它使用 Zeus 网络服务器,前两条规则运行良好。然而,它似乎并没有与第三个网址打球,其中有一个查询字符串......关于如何解决这个问题的任何想法?好像我可能需要一个正则表达式来处理特殊字符?,因为如果我把它从比赛中去掉,它就可以正常工作。谢谢

match URL into $ with ^/$
if matched
set OUT:Location = http://www.website.co.uk/
set OUT:Content-Type = text/html
set RESPONSE = 301
set BODY = Moved
goto END
endif

match URL into $ with ^/index.php$
if matched
set OUT:Location = http://www.website.co.uk/
set OUT:Content-Type = text/html
set RESPONSE = 301
set BODY = Moved
goto END
endif

match URL into $ with ^/index.php?cPath=1_50$
if matched
set OUT:Location = http://www.website.co.uk/categories.php?category=Boilers
set OUT:Content-Type = text/html
set RESPONSE = 301
set BODY = Moved
goto END
endif

【问题讨论】:

    标签: regex redirect zeus


    【解决方案1】:

    我不熟悉 Zeus url 重写。但如果它使用标准正则表达式,则需要使用反斜杠转义 ?

    match URL into $ with ^/index.php\?cPath=1_50$
    

    问号通常是一个元字符,它修改前面的字符或表达式,使其成为可选的。所以你现在的模式将匹配/index.phpcPath=1_50/index.phcPath=1_50

    【讨论】:

    • 是的,已经解决了。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2018-12-03
    • 2023-03-03
    • 1970-01-01
    • 2014-07-20
    • 2017-08-26
    • 2011-01-21
    • 2021-04-28
    • 1970-01-01
    相关资源
    最近更新 更多