Kohana的 - 控制特定的.htaccess [英] Kohana - controller specific .htaccess

查看:170
本文介绍了Kohana的 - 控制特定的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置一个特定的Kohana的控制器一些htaccess的规则。基本上,它做的形式上传。大多数网站不希望让大量上载,以便php.ini中仍将使用建议设置。

I'm trying to set some htaccess rules for a specific Kohana controller. Basically its to do with form uploads. The majority of the site doesn't want to allow for large uploads so the php.ini will remain with the recommended settings.

然而,在一个地方大文件的上传是必需的。我有以下几种选择在我的根目录的.htaccess添加:

However in one place a large file upload is required. I have the following options to add in my root .htaccess:

php_value max_input_time 60000
php_value post_max_size "1GB"
php_value upload_max_filesize "1GB"
php_value memory_limit "128MB"

但我不知道该怎么做,使之适用于只为一个控制器(即 HTTP:// WWW .mysite.com / massiveupload )。

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

还有另一种解决方案。再次感谢@LazyOne的小费。这一个是非常巧妙的,但它需要直接更新Apache的配置(所以你不能一个共享的主机部署)。

There's also another solution. Again thanks to @LazyOne for the tip. This one is much neater, but it requires updating the Apache config directly (so you cannot deploy it on a shared hosting).

所有你需要做的就是它添加到你的httpd.conf或vhosts.conf(内部<目录> <虚拟主机> 按照 Apache的文档)。

All you have to do is add this to your httpd.conf or vhosts.conf (inside <Directory> or <VirtualHost> as per Apache Docs).

<LocationMatch /massiveupload>
    php_flag max_input_time 60000
    php_value post_max_size 1024M
    php_value upload_max_filesize 1024M
    php_value memory_limit 128M
</LocationMatch>

重新启动服务器,它应该只是工作!

Restart your server and it should just work!

请注意,尽管LocationMatch解析 / massiveupload 作为一个经常性的前pression,我们不能使用 ^ / massiveupload (注意 ^ 字符匹配字符串的开头)。这是因为如果你使用ModRewrite(在内部改变最后的请求URL),它会失败。

Note, that although LocationMatch parses the /massiveupload as a regular expression, we cannot use ^/massiveupload (note the ^ char to match beginning of the string). This is because it will fail if you use a ModRewrite (which changes the final request url internally).

请注意,你不应该让的upload_max_filesize 的post_max_size 完全相同的尺寸,因为如果你上传的文件刚刚到达的upload_max_filesize 的限制,任何其他职位的数据将导致它超过了的post_max_size 和表单提交将失败

Note, you shouldn't make upload_max_filesize and post_max_size the exact same size, because if you upload a file that just reaches the upload_max_filesize limit, any other post data will cause it to exceed the post_max_size and the form submission will fail.

这篇关于Kohana的 - 控制特定的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆