我在Apache / 2.4.2-win32服务器上有以下.htaccess:
# Turn mod_rewrite on
RewriteEngine On
# Allow direct loading of files in the static directory
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/?static/(.+)$ - [L]
# Send all other requests to controller
RewriteCond ${REQUEST_URI} !^/?(spf/index\.php)?$
RewriteRule .* spf/index.php [L,QSA]
这很好用,完全符合我的要求。对于那些无法解决问题的人,它会通过spf/index.php
发送所有请求,除非它们是针对static
目录中存在的文件。
该文件位于虚拟主机的文档中。
通过此.htaccess发出的每个请求都会产生以下错误:
[Wed Aug 01 14:14:16.549835 2012] [core:warn] [pid 7100:tid 1076] AH00111: Config variable ${REQUEST_URI} is not defined
这实际上并没有导致问题 - 每个请求都按预期工作 - 但它填满了我的错误日志,我不喜欢它。
根据Google,之前没有人犯过这个错误。就我调试它而言,我真的不知道下一步该去哪里。
任何人都知道这里发生了什么?
P.S。我知道这可能是一个更适合SF的问题,如果一般意见是它不属于这里我会移动它。
答案 0 :(得分:10)
您需要将$
替换为%
:
RewriteCond ${REQUEST_URI} !^/?(spf/index\.php)?$
到
RewriteCond %{REQUEST_URI} !^/?(spf/index\.php)?$