Development and databases

Change PHP options with the selector or .htaccess

Reviewed on 2 min read php htaccess

To adjust PHP, start with Select PHP Version > Options in cPanel. Choose the version the website uses and change only the value the application needs. A rule in .htaccess can be an alternative when the PHP handler and the directive support that method.

Before changing a value

Note the current value, the PHP version and the application's folder. Keep a copy of .htaccess outside the public root. If several websites use the same version, check whether a selector option could affect all of them.

The value should meet a specific need. For example, for a form that sends more fields than allowed, you might need to raise max_input_vars. Do not raise it to an outsized number to fix any saving error.

Example with php_value

If the server supports this directive in .htaccess, an example would be:

php_value max_input_vars 3000

The number is only a guide: use the one your application requires and check the effective value. Boolean options can use php_flag, but not every PHP directive can be changed from a directory.

php_value is not supported by every handler. If the website returns a 500 error, remove the line you added and check that it recovers; do not keep adding rules. Then use the selector or ask support for the method supported for that domain. Do not mix php.ini, .user.ini and .htaccess instructions: they have different syntax and scope.

Check the result

Check the value from the application or with a protected temporary test in the same folder, and delete it when you finish. A check from the terminal does not show the effective value in a web request.

Then test the operation that was failing. If the problem continues, check its logs and the server's response: a form, web server or memory limit is not necessarily solved by changing that directive.

The plan's resource limits still apply. Raising a PHP value does not on its own increase the RAM, CPU or execution capacity allocated to the hosting.

You may also find useful

Something wrong or out of date? Tell us and we will review it.