【发布时间】:2009-07-05 23:33:04
【问题描述】:
我正在尝试使用 .htaccess 文件和 Apache 创建条件重写规则。
基本上我需要的是 Apache 会检查请求的文件是否存在于子文件夹中,在这种情况下 Apache 会为这个现有文件提供服务,或者,如果文件不存在,Apache 会加载 index.php 文件.
我使用的文件夹结构是:
- /gallery
- /cache
- index.php
- .htaccess
另外,我现在拥有的 .htaccess 是
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*)$ index.php/$1 [L]
但是,这仅在我要查找的文件位于 /gallery 文件夹中时才有效,但是我需要查看该文件是否存在于 /cache 文件夹中。
有谁知道如何修改此规则以实现这一目标?
提前谢谢你,
标题
【问题讨论】:
-
我不认为 mod_rewrite 可以做到这一点,但我有兴趣看看它是否可能。
标签: .htaccess mod-rewrite