Decent Dabbler
Decent Dabbler

Reputation: 22773

IIS: .htaccess php_flag / php_value alternative?

For IIS (5.0 or higher), are there alternatives to apache's .htaccess directives php_flag and php_value to set PHP_INI_PERDIR config values?

Thanks.

Upvotes: 6

Views: 2454

Answers (2)

Pang
Pang

Reputation: 10110

Since PHP 5.3.0, you can use .user.ini files.

  1. Do a phpinfo(), and find these entries:

    • user_ini.filename, and
    • user_ini.cache_ttl.

    user_ini entries in phpinfo()

  2. user_ini.filename is the name of the per-directory config file. Its value is usually .user.ini.

  3. Create the file .user.ini and put it in the directory you want to config.
  4. The format of .user.ini is just like php.ini. For example, it may contain something like this:

    ; Override value of upload_max_filesize
    upload_max_filesize = 4M
    
  5. Run phpinfo() again to check that the value has been overridden by your .user.ini.

Notes:

  1. For performance reasons, the .user.ini file is cached, so you may have to wait until the cache expires. The timeout is specified by user_ini.cache_ttl. For example, if user_ini.cache_ttl is 300, it means that the .user.ini file is cached for 300 seconds.
  2. The config file name is .user.ini, starting with a dot.
  3. This technique works for CGI/FastCGI SAPI only. See the doc for details.

Upvotes: 2

Oliver Maksimovic
Oliver Maksimovic

Reputation: 3262

Unfortunately, it seems that PHP_INI_PERDIR values cannot be modified (only PHP_INI_USER can). Here is the official information from php.net regarding changes of PHP configuration on Windows:

http://www.php.net/manual/en/configuration.changes.php#configuration.changes.windows

Upvotes: 2

Related Questions