I'm using kohana 3 for a project and have a controller /foo with various actions (/foo/about, /foo/features, et cetera). However, I was just recently given a couple folders with a fairly large html site to be placed within this directory including html/txt/picture files. I now have a structure that looks like this
我正在使用kohana 3进行项目,并且有一个带有各种动作的控制器/ foo(/ foo / about,/ foo / features等等)。但是,我最近刚给了一个带有相当大的html网站的文件夹,放在这个目录中,包括html / txt / picture文件。我现在有一个看起来像这样的结构
- kohana/foo/help/index.html
- Kohana的/富/帮助/ index.html的
- kohana/foo/help_de/index.html
- Kohana的/富/ help_de / index.html中
- kohana/foo/help_es/index.html
- Kohana的/富/ help_es / index.html中
and so on..
等等..
My application serves these files just perfectly, however, when I go to the /foo controller - it no longer works. I can solve this problem by editing my htaccess file to be as such:
我的应用程序完美地提供这些文件,但是,当我去/ foo控制器时 - 它不再有效。我可以通过编辑我的htaccess文件来解决这个问题:
RewriteRule ^(?:application|modules|system|foo)\b.* index.php/$0 [L]
However, then, my static files don't get served. What can I do to serve the static files if they exist but default back to my controller/actions when they don't?
但是,我的静态文件无法提供服务。我可以做什么来提供静态文件(如果它们存在)但默认返回我的控制器/操作时它们不存在?
I've been trying to edit the htaccess to only serve files from the list of folders but cannot figure out the proper way to go about doing this.
我一直在尝试编辑htaccess只提供文件夹列表中的文件,但无法找出正确的方法来执行此操作。
Please let me know if I must be more descriptive.
如果我必须更具描述性,请告诉我。
Thank you -
谢谢 -
Edit (full .htaccess):
编辑(完整.htaccess):
RewriteEngine On
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]
2 个解决方案
#1
0
The /foo
link is being broken by this line:
/ foo链接被这一行打破:
RewriteCond %{REQUEST_FILENAME} !-d
Because /foo
is being seen as a directory. You could probably just remove that line, as long as you aren't worried about losing directory indexes.
因为/ foo被视为目录。您可以删除该行,只要您不担心丢失目录索引即可。
#2
0
I dont know kohana, but I imagine it can work if you add in your .htacess after "RewriteEngine on" 2 lines:
我不知道kohana,但我想如果你在“RewriteEngine on”2行之后添加你的.htacess它可以工作:
RewriteEngine on
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f #Exlude files RewriteCond %{REQUEST_FILENAME} !-d #Exlude directories
RewriteCond%{REQUEST_FILENAME}!-f #Exlude files RewriteCond%{REQUEST_FILENAME}!-d #Exlude directories
This will exclude files and directories from beign processed.
这将从beign处理中排除文件和目录。
#1
0
The /foo
link is being broken by this line:
/ foo链接被这一行打破:
RewriteCond %{REQUEST_FILENAME} !-d
Because /foo
is being seen as a directory. You could probably just remove that line, as long as you aren't worried about losing directory indexes.
因为/ foo被视为目录。您可以删除该行,只要您不担心丢失目录索引即可。
#2
0
I dont know kohana, but I imagine it can work if you add in your .htacess after "RewriteEngine on" 2 lines:
我不知道kohana,但我想如果你在“RewriteEngine on”2行之后添加你的.htacess它可以工作:
RewriteEngine on
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f #Exlude files RewriteCond %{REQUEST_FILENAME} !-d #Exlude directories
RewriteCond%{REQUEST_FILENAME}!-f #Exlude files RewriteCond%{REQUEST_FILENAME}!-d #Exlude directories
This will exclude files and directories from beign processed.
这将从beign处理中排除文件和目录。