【问题标题】:htaccess redirect only if it has value after forward slashhtaccess 仅当它在正斜杠后具有值时才重定向
【发布时间】:2017-05-25 03:08:05
【问题描述】:

仅当/events/ 的正斜杠后有值时,我才想应用以下 htaccess 规则

如果我访问/events/(不要做任何事情。不要应用 htaccess 规则)

但是如果我访问/events/this-can be-anything/(应用下面的htaccess规则)

RewriteRule ^events/(.*) /lp/events/index.php [L]

这显然行不通。

【问题讨论】:

    标签: .htaccess mod-rewrite


    【解决方案1】:

    您需要将您的正则表达式模式 (.*) 更改为 (.+) 以匹配 uri 之后的至少一个字符。

    RewriteRule ^events/(.+)$ /lp/events/index.php [L]
    

    【讨论】:

      猜你喜欢
      • 2019-01-05
      • 2015-06-19
      • 2014-10-04
      • 2018-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-10
      相关资源
      最近更新 更多