【发布时间】:2011-07-12 23:32:13
【问题描述】:
我正在使用 zend 框架,它有一个漂亮的示例 .htaccess 用于将不存在的位置重定向到 index.php 以由框架处理:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /site/index.php [NC,L]
这里是 /site 的 apache 配置
Alias /site "/path/to/zf/project/public"
<Directory "/path/to/zf/project/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
在我们升级站点时,我想将所有流量重定向到特定文件(例如,offline.html),但特定 IP(例如 127.0.0.1)除外,因此我尝试使用此规则在 apache 配置中:
<Location />
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
RewriteCond %{REQUEST_URI} !/offline\.html$
RewriteRule .* /offline.html [R=302,L]
</Location>
这似乎可行,但由于某种原因,它使我的 .htaccess 文件似乎无法正常工作。我可以很好地访问 /site,但我不能更深入地访问,例如 /site/controller/action。
谢谢!
【问题讨论】:
标签: apache zend-framework .htaccess mod-rewrite