Using php_flag or php_value in .htaccess files

The "php_value" or "php_flag" commands in .htaccess files are recommended by PHP scripts. Here is an example of them:

    php_value  include_path         ".:/usr/local/lib/php"
    php_flag   display_errors       Off
    php_value  upload_max_filesize  2M

Here is the list of PHP values that you can change using .htaccess

php_flag session.use_trans_sid On
php_flag session.use_only_cookies on
php_flag register_globals On
php_value magic_quotes_runtime On
php_flag magic_quotes_gpc off
php_admin_flag safe_mode Off
php_value post_max_size 2048
php_value upload_max_filesize 15M
php_value memory_limit 128M
php_value max_execution_time 300
php_value magic_quotes_gpc off
php_flag session.bug_compat_warn off
php_value session.use_cookies 1
php_flag session.use_only_cookies 1

Please note that you can't use "php_value" or "php_flag" commands in .htaccess files. If you do it, an "internal server error" message will be displayed.

Another way to have the same effect is by modifying of php.ini file. It’s flexible and through it you can override many PHP settings as opposed to .htaccess files.

You can look for PHP support page, where will find more instructions on modifying php.ini. It’s necessary to add the following lines to your custom php.ini file in order to have the same effect as the .htaccess lines above:

    include_path = ".:/usr/local/lib/php"
    display_errors = Off
    upload_max_filesize = 2M

Was this article helpful?

mood_bad Dislike 7
mood Like 5
visibility Views: 11028