【问题标题】:RewriteRule cannot compile regular expressionRewriteRule 无法编译正则表达式
【发布时间】:2009-10-07 14:09:24
【问题描述】:

我以前的服务器工作正常。今天我更换了新服务器,并且 RewriteRule 无法在我的 htaccess 上编译正则表达式。

如何修复这条线。

RewriteRule ^category/([0-9]+)(?:/([^/]+)(?:/([^/]+))?)(?:/([^/]+)(?:/([^/]+))?)?/$ ./category.php?pid=$1&catname=$2&page=$3 [L]

让我知道:)

【问题讨论】:

    标签: regex .htaccess mod-rewrite


    【解决方案1】:

    您可能正在使用具有不同正则表达式引擎的不同 Apache 版本。自 1.3 起的 Apache 版本使用 POSIX ERE,而自 2.0 起的版本使用 PCRE。而且只有PCRE支持非捕获组(?:expr)

    所以试试没有它们的模式:

    RewriteRule ^category/([0-9]+)(/([^/]+)(/([^/]+))?)(/([^/]+)(/([^/]+))?)?/$ ./category.php?pid=$1&catname=$3&page=$5 [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-30
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多