Kohana 模块 -path .htaccess 保护和媒体文件
在 Kohana
中,.htaccess
中有 modules
-path 保护,
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
我如何允许这样的路径:
http://localhost/modules/mymodule /media/js/myjavascript.js
我想将 javascript 和其他媒体文件包含到我的模块中,并仍然保护其他模块文件,例如 .php
我可以允许整个 modules< /code> -path,但然后全部
.php
-文件也会被列出。
# Protect application and system files from being viewed
RewriteRule ^(?:application|system)\b.* index.php/$0 [L]
当然有基本的 PHP 保护,但我仍然不希望任何人可以列出我的 modules
-path。
<?php defined('SYSPATH') or die('No direct script access.');
In Kohana
there's modules
-path protection in .htaccess
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
How could I allow paths like:
http://localhost/modules/mymodule/media/js/myjavascript.js
I would like to include javascript and other media files to my module and still protect other module files like .php
I could allow whole modules
-path, but then all .php
-files would be listed too.
# Protect application and system files from being viewed
RewriteRule ^(?:application|system)\b.* index.php/$0 [L]
Sure there is basic PHP -protection, but I still won't want that anyone could list my modules
-path.
<?php defined('SYSPATH') or die('No direct script access.');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的解决方案是使用媒体控制器来提供这些文件。因此,用户可以请求“js/script.js”,Kohana 将使用级联文件结构加载它找到的第一个文件。 Kohana 附带了一个很好的媒体控制器,它位于用户指南模块中:
classes/controller/userguide.php 第 247 行
这不会是最快的解决方案,但如果您正确设置响应标头,文件应该缓存在客户端浏览器。
The best solution would be to serve those files using a media controller. So a user could request "js/script.js" and Kohana would load the first file it finds using the cascading file structure. There's a good media controller that comes with Kohana, it's in the Userguide module:
Line 247 of classes/controller/userguide.php
This wont be the fastest solution, but if you correctly set the response headers the files should be cached on the client browser.
解决方案,在RewriteRule之前添加这个RewriteCond
Solution, add this RewriteCond just before RewriteRule