Using the .Htaccess File for PHP Directives

The .htaccess file is pretty handy as it can also allow you to set various PHP flags that you may not want enable for all of you websites and in turn will let you run just about every PHP flag or directive on a one on one website basis.

You will need to log into your Linux server directly using SSH. If you are not familiar on how to do this, we have articles on how to implement this on both Windows and Mac;

Windows –
Mac –

To create the .Htaccess file, you meerly need to create a text file with any Linux editor. The file must be called .htaccess and it must exist in the root directory of the website you want override the Php global directives for.

The format of the .htaccess is simple, however you will want to comment out exactly what flag or directive you are enabling for the site. An example of this would be as seen below;

#Turn register goabls of
php_value register_globals off

#Php max upload size
php_value upload_max_filesize 12M
php_value post_max_size 12M

#Enable another version of php if you have two installed (Enable Php 5)
AddType application/x-httpd-php5 .htm .html .php

Make sure you save the file when you are done editing it.

Just about any directive or flag can be added to the .htaccess file so you can commently customize the php functions of the website instead of changing it globally in the php.ini file. For a list of what you can use, please review the PHP manual at