【问题标题】:rewrite everything except files and directories重写除文件和目录之外的所有内容
【发布时间】:2014-04-02 23:25:12
【问题描述】:

我想为现有文件或文件夹以外的所有内容创建一个 .htaccess 重写规则,但无法弄清楚问题所在。

我现在的代码是这样的。

RewriteEngine on
RewriteCond %{REQUEST_URI} !(-f|-d)$
RewriteRule .* index.html

我不想为除了已经存在的文件和文件夹之外的所有内容创建规则,以防我在服务器上创建其他内容。

重写工作正常,但例外没有。

【问题讨论】:

    标签: html .htaccess mod-rewrite


    【解决方案1】:

    满足这种需求的正确代码是

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f #exeption for files
    RewriteCond %{REQUEST_FILENAME} !-d #exeption for dirs
    RewriteRule .* index.html
    

    【讨论】:

      猜你喜欢
      • 2011-03-11
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2011-07-19
      • 1970-01-01
      • 2010-10-06
      • 1970-01-01
      • 2013-10-30
      相关资源
      最近更新 更多