【问题标题】:mod_speling & mod_rewrite to work together?mod_speling & mod_rewrite 一起工作?
【发布时间】:2010-12-31 00:39:27
【问题描述】:
    CheckSpelling On

    RewriteEngine   on
    RewriteCond     %{HTTP_HOST}                      ^([^.]+)\.example\.com$
    RewriteCond     /home/%1/                          -d
    RewriteRule     ^(.+)                              %{HTTP_HOST}$1
    RewriteRule     ^([^.]+)\.example\.com/media/(.*)     /home/$1/data/media/$2
    RewriteRule     ^([^.]+)\.example\.com/(.*)           /home/$1/www/$2

CheckSpelling On (mod_speling) 在 www.example.com 时可以正常工作。但是当重写发生时它不起作用。例如有一个/home/test/www/index.html 文件。如果您执行test.example.com/INDEX.html,它不会修复为test.example.com/index.html,但如果您执行www.example.com/INDEX.html(没有/home/www/ 文件夹),它将修复为www.example.com/index.html

似乎它首先通过 mod_rewrite 处理,如果它使用 rewrite,它不会通过检查拼写。我试过以不同的顺序加载模块,但没有成功。

【问题讨论】:

    标签: apache mod-rewrite apache2 case-insensitive mod-speling


    【解决方案1】:

    mod_speling 无法查找通过mod_rewrite 规则的拼写替代项。如果您使用重定向 [R],它应该可以工作,但看起来您想隐藏实际目录。

    您可以考虑使用自定义 404 而不是 mod_speling。

    【讨论】:

    • 奇怪。我有一个 6 个月前工作的设置,我忘记了我是怎么做的或做了什么。从那以后,我已经失去了 50% 的自定义内容;[
    【解决方案2】:

    当在每个目录上下文(或 htaccess)中使用重写时,mod_speling 和 mod_rewrite 在同一阶段运行。此阶段运行所有个参与模块,而不是第一个采取任何行动的模块。

    在每个目录中重写总是表现得好像它有 [PT] 标志。如果您的重写不在每个目录的上下文中,只需添加 [PT] 标志并在您的替换中使用 URI 而不是文件名可能会使它们互操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-13
      • 2012-06-01
      • 1970-01-01
      • 2011-03-08
      • 1970-01-01
      • 1970-01-01
      • 2010-09-27
      • 1970-01-01
      相关资源
      最近更新 更多