【问题标题】:htaccess redirect with parametershtaccess 带参数重定向
【发布时间】:2012-09-25 14:51:33
【问题描述】:

希望使用 2 个参数重定向页面,我所拥有的是

RewriteEngine On

RewriteCond %{QUERY_STRING} ^([^&]&)*id=8(&|$)

RewriteCond %{QUERY_STRING} ^([^&]&)*date=1349996400(&|$)

RewriteRule ^/calendar/event\.php$ /news/nrsc-chloramines-open-house/ [R=301,L]

【问题讨论】:

    标签: .htaccess mod-rewrite redirect url-rewriting


    【解决方案1】:

    您需要去掉正则表达式中的前导斜杠。通过 htaccess 文件中的重写规则发送的 URI 已去除前导斜杠。此外,您可以使查询字符串的开始边界匹配更好一些:

    #                             v--- make it match beginning or &
    RewriteCond %{QUERY_STRING} (^|&)id=8(&|$)
    RewriteCond %{QUERY_STRING} (^|&)date=1349996400(&|$)
    #             v---- make optional
    RewriteRule ^/?calendar/event\.php$ /news/nrsc-chloramines-open-house/ [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-01
      • 2013-04-07
      相关资源
      最近更新 更多