Changing php.ini directives via .htaccess

A script you want to use requires a different setting then we have set?  No problem, you can change the setting via .htaccess -- php.ini would be used in a different setup and you can take the same directives that you would need to change and apply them to the .htaccess.

To change PHP settings via .htaccess, please do the following:

  1. Edit or create a .htaccess file via file manager or a text editor (basic text editor such as notepad) -- this is a simple text file with no special requirements
  2. There are two different directive types you need to use for different setting types
    1. php_value -- Used for strings (text) and integers (numbers)
    2. php_flag -- Used for boolean settings -- true, false, on, off, 1, 0
  3. Find the value you need to use at the php.ini directive list and find what type it is.
  4. Put the setting directive in to the .htaccess with the following syntax:
    • php_value/flag setting_name value
  5. Save the .htaccess file to the directory that the script is in or one of the parent directories.  If you want this file to be global throughout all your domains and subdomains, put the .htaccess file within your home directory -- the directory that holds all your domain directories.
  6. Test your script for the new settings and you're done.

NOTE: Not all php.ini directives can be changed via .htaccess.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Disable Pagespeed

On our shared servers, we have pagespeed module enabled in nginx (the front web server).  This...

Select PHP Version - Plesk

To select a version of PHP within the Plesk control panel, please do the following: Login in...

PHP 5.6, 7.0 Fails to connect via SSL / TLS

Starting at PHP 5.6, PHP does a verify of the SSL certificate and if it fails to the connection...

Force WWW or non-WWW

NONE SSLTo force www in your URLs, place the following in the .htaccess.RewriteCond %{HTTP_HOST}...

PHP settings and the .user.ini file

Most settings for PHP can be configured via a file called ".user.ini" as defined by the...