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

查看:70
本文介绍了每个目录的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

不幸的是,我无法直接在我的虚拟主机的<Directory>中执行此操作,因为目录始终是相同的(我使用的是前端控制器,因此所有请求都通过index.php& amp;发送到合适的控制器-我使用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.

推荐答案

这是可能的,具体取决于您映射到前端控制器的方式.如果通过重写规则进行操作,则可以使用<Location>而不是<Directory>块来指定要更改其设置的路径块. <LocationMatch>允许您将正则表达式用于同一件事.

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天全站免登陆