【发布时间】:2011-09-26 13:44:58
【问题描述】:
我有这样的情况。 我正在 Zend Framework 中开发应用程序,并且 htaccess 将每个请求指向 索引.php。如果请求路径上存在某些文件或目录,则 htaccess 允许访问这些文件,如 css、js、图像等...
现在我有例如这样的链接:
example.com/profile/martin-slicker-i231
使用 Zend Router,它指向控制器帐户和操作视图配置文件。我想为我的用户添加一些头像,并在公用文件夹中创建了目录(因此服务器可以像 css 和 js 一样访问图像)。该目录名为“profile”,其中的子目录为“martin-slicker-i231”。服务器可以看到所有路径:
public/
.htaccess
index.php
profile/
martin-slicker-i231/
avatar-small.jpg
问题是当我将浏览器指向 example.com/profile/martin-slicker-i231 时 将我指向此目录而不是控制器和操作。当我使用用户删除文件夹时,流程将转到控制器和操作。如何配置 .htaccess 以便 example.com/profile/martin-slicker-i231 将指向控制器和操作,但请求 example.com/profile/martin-slicker-i231/ avatar-small.jpg 指向文件。这是我的 .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
有人可以帮忙吗?
【问题讨论】:
-
@Marcin - 看起来下面的答案对你有所帮助......也许你应该接受它是正确的??
标签: php zend-framework .htaccess apache2 directory