【问题标题】:Can't get Apache mod_rewrite to ignore a directory无法让 Apache mod_rewrite 忽略目录
【发布时间】:2014-07-24 15:04:42
【问题描述】:

我试图让 Apache mod_rewrite 忽略某些目录。这是我的 httpd.conf 的一部分:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^(img|css|js)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

如果我去http://example.com/img/random_path,我仍然看到index.php生成的错误信息(而不是默认的错误页面)。

【问题讨论】:

  • /img/ 中也有 .htaccess 吗?
  • 使用跳过标志S=1 避免下一条规则

标签: apache .htaccess mod-rewrite


【解决方案1】:

我认为你可以使用这个规则条件

RewriteCond %{REQUEST_URI} !\/img\/

在重写规则之前。它可以防止重写包含“/img/”字符串的url。

【讨论】:

    猜你喜欢
    • 2018-04-04
    • 1970-01-01
    • 2010-09-14
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    • 2018-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多