.htaccess versus php.ini for php options

Question:

What is the difference between php.ini and .htaccess for php options? When should I use php.ini and when should I use .htaccess?

Answer:

You should use .htaccess only when you are running php via mod_php. This is a setting in your control panel “php” section.

php options inside .htaccess files have no effect when running as a cgi.

You can change your php versions from cgi to mod_php inside your control panel in the php section.

When php is run as mod_php, php is built into the webserver and the webserver can understand the php directives inside .htaccess

When php is running as a cgi, the webserver does not understand the php directives inside a .htaccess file. Instead you must create the directy “etc” and put a php.ini file inside it. When your php parser starts it will read these the directives inside php.ini and process them.

Leave a Reply

Your email address will not be published. Required fields are marked *