Override php.ini setting via .htaccess

Sometimes you need to edit the php.ini settings to meet your website requirement, but as for live server such as a hosting server, you do not have the access to. The solution is to edit the setting accordingly from your .htaccess file under your website root. Two PHP directives are permitted within .htaccess:

    * php_flag <flag-name> on|off
    * php_value <flag-name> <flag-value>

php_flag should be used for on/off values, whereas php_value can be used for any others. For example, the following .htaccess file will disable globals, set the maximum file upload size to 20MB, and allow PHP scripts to run for 10 minutes (600 seconds):

php_flag register_globals off
php_value upload_max_filesize 20M
php_value max_execution_time 600

But please keep in mind it’s not working for all servers depends the server end restriction.


- has written 121 posts.

Leave a Reply

You must be logged in to post a comment.