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 return an item in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

Why should you update APP_URL from from http://localhost?

How to get table column names from a database table in Eloquent?

How to provide a default model object for relationships?

How to group a SQL statement in brackets/parenthesis

When is __destruct called in PHP?

What is the spaceship operator (<=>) in PHP?

How to output (echo/print) content in PHP

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

How to hide the server signature (hide Apache info) from HTTP headers with .htaccess