每个目录的 PHP ini 指令取决于 request_uri [英] PHP ini directive per directory depending of request_uri

查看:31
本文介绍了每个目录的 PHP ini 指令取决于 request_uri的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改上传的大小限制.我知道我必须在 Apache 配置中更改这些指令(有些不能使用 ini_set 更改)

I'm trying to change the size limit of an upload. I know I have to change those directive, in Apache configuration (some can't be changed using ini_set)

php_value session.gc_maxlifetime 3600
php_value max_input_time         3600
php_value max_execution_time     3600
php_value upload_max_filesize    10M
php_value post_max_size          110M

不幸的是,我不能直接在我的虚拟主机的 中这样做,因为目录总是相同的(我使用的是前端控制器,因此所有请求都通过index.php & 被分派到适当的控制器 - 我使用 Symfony)

Unfortunately, I can't do that directly in a <Directory> of my virtualhost, since the directory is always the same (I'm using a front controller, thus all request go through index.php & are dispatched to the proper controller - I use Symfony)

那么,我的问题是如何避免这个问题?我不想为整个应用程序设置这些值,只想为特定操作设置这些值.

My question, then, is how can I avoid this problem ? I don't want to set those values for the whole application, only for a specific action.

推荐答案

这是可能的,这取决于您映射到前端控制器的方式.如果你通过重写规则来做,那么你可以使用 而不是 块来指定要更改的路径块设置为. 允许您使用正则表达式来处理相同的事情.

This is possible, depending on how you map to your front controller. If you're doing it via rewrite rules then you can use a <Location> instead of <Directory> block to specify a chunk of path you want to change the settings for. <LocationMatch> lets you use a regexp for the same thing.

如果您的所有外部 URL 确实以 /index.php? 开头,那么请考虑为这些请求设置重定向规则:

If all of your external URLs really start with /index.php? then consider setting up a redirect rule especially for these requests:

RewriteEngine on
RewriteRule ^foo/$ ^/index.php [L]

<Location /foo/>
    php_value ...
</Location>

如果情况并非如此,您需要告诉我们更多有关您的应用程序结构的信息.

If that's not the case, you'll need to tell us more about your application structure.

这篇关于每个目录的 PHP ini 指令取决于 request_uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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