Set PHP config Variables (like ini_set) with .htaccess

Apache: Set PHP config Variables (like ini_set) with .htaccess

If you need to set some PHP config variables (the same as in php.ini or via ini_set()) you can do this in .htaccess

  1. php_value upload_max_filesize 150M
  2. php_value  include_path  ".:/usr/local/lib/php"
  3. php_value error_log  "/log/location/php_errors.log"

If you need to switch something from on to off (true/false) then you must use php_flag:

  1. php_flag display_errors off

If apache is run in CGI mode this will not work.

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about Set PHP config Variables (like ini_set) with .htaccess

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Apache language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to see all of the options for an artisan command?

How to Enable Directory Listings in Apache with .htaccess

How to find out which php.ini file PHP is using?

How to find the 2nd most common item in an array?

How to autoload helper files with composer?

How to undelete a soft deleted Eloquent row?

How to redirect your website to a new domain/location in .htaccess

What are Template literals (Template strings) in JS?

How to get the first row that matches some where queries, or create it if it doesn't exist (in Laravel's Eloquent)?

How to find the average value of items in a Laravel Collection?