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 set environmental variables in your .htaccess file

How to set up an alias to map one directory to another destination

What is snake case?

What are Template literals (Template strings) in JS?

How to reverse htmlentities() / What is the opposite of htmlentities()?

How to check if an object or variable is an array, in JS?

How do you launch the PHP interactive shell?

How to round a number in JS?

How to force SSL in Apache's .htaccess?

How to have a whitelist of IP addresses that can access files in .htaccess