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 have a whitelist of IP addresses that can access files in .htaccess

How to namespace a Laravel route group?

How to add a name prefix to all routes in a group?

How to return an item in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

How to query mysql using PDO in PHP?

When is __destruct called in PHP?

How to pick what array_intersect function to use in PHP?

How to fix the MySQL related "Specified key was too long error" error in Laravel

Force trailing slash (redirect if no trailing slash exists) in .htaccess

PHP Date commonly used formats