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 get the type of a variable in JS?

What are some ways you can log debug messages and data in JS?

How to return JSON data to the user in Laravel?

How to use Anonymous classes in PHP 7?

How to query mysql using PDO in PHP?

Remove trailing slash (redirect to remove trailing slash) in .htaccess

How to Extract Query String (from a URL) Into an Associative Array in PHP

PHP Date commonly used formats

How to increment a value in the database

What kind of database field type should you (normally) use for foreign keys?