How to Create htaccess File in PHP

by Mike Lugar
image title

Learning how to create htaccess file in php is not possible as the .htaccess file can be used to control a number of PHP settings. Htaccess files are actually distributed configuration files and allow you to make a number of configuration changes on a directory basis. This means that you have the ability to have a different configuration for each directory of your website making it a very useful.

Through a .htaccess file you have the ability to set any php.ini values and it is very simple to do. This is also an option if your web host does not allow modification of the default php.ini file.

The standard syntax to be placed in the .htaccess file to adjust php_values is as follows:


Additionally, for on or off adjustments php_flag can be used:


The below examples show how the above standard syntax can be used for any PHP settings. This is not a complete list as there many settings that are not covered below. Also in the below examples you can update the values or flags to what you require for your specific instance.

Setting Examples


Max Execution Time


Display PHP Errors


Maximum PHP File Upload Size


PHP Script Memory Limit


Maximum Number of PHP Input Variables

Mike is the managing member at MSLtek and is an avid web consultant and web developer. He enjoys solving complex problems and building awesome stuff.

Posted on September 8, 2016

Leave a Reply

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

Would you like us to send you a quote?

Get A Quote