【问题标题】:Lighttpd Redirect url to Lowercase VersionLighttpd 将 url 重定向到小写版本
【发布时间】:2012-05-13 19:33:13
【问题描述】:

我正在使用 lighttpd,我想将大写 url 重定向到小写。

例如,如果我有以下网址: http://test.com/info/code/BDAY

我想将其重定向到: http://test.com/info/code/bday

最好的方法是什么?

【问题讨论】:

    标签: redirect rewrite lighttpd


    【解决方案1】:

    Lighttpd 内部的 mod_rewrite 和 mod_redirect 只能处理模式匹配和替换,无法进行字符转换。

    您可以有一个匹配任何大写字符并将 URL 传递给执行重写并返回重定向的脚本的模式

    lighttpd.conf:

    url.rewrite-once += ( "(.*[A-Z].*)" => "lower.php?url=$1" )
    

    lower.php:

    <?php header("Location: " + strtolower($_GET['url']));
    

    【讨论】:

      猜你喜欢
      • 2021-07-15
      • 2021-01-19
      • 2010-11-08
      • 1970-01-01
      • 2016-05-23
      • 1970-01-01
      • 2013-11-05
      • 2017-12-04
      • 1970-01-01
      相关资源
      最近更新 更多