Tag Archive | ".htaccess"

Tags: ,

How to setup custom error via .htaccess

You can modify .htaccess file under your website root to setup custom error. The syntax is like that:

ErrorDocument <3-digit-http-status-code> Action

Following are some samples:

ErrorDocument 500 /cgi-bin/500.html
ErrorDocument 500 "Sorry, our script crashed."
ErrorDocument 500 http://www.yourdomain.com/
ErrorDocument 404 /error/not_found.html

Ref: http://httpd.apache.org/docs/1.3/custom-error.html


Posted in Linux-Apache-PHPComments (0)

Tags: ,

Override php.ini setting via .htaccess

Sometimes you need to edit the php.ini settings to meet your website requirement, but as for live server such as a hosting server, you do not have the access to. The solution is to edit the setting accordingly from your .htaccess file under your website root. Two PHP directives are permitted within .htaccess:

    * php_flag <flag-name> on|off
    * php_value <flag-name> <flag-value>

php_flag should be used for on/off values, whereas php_value can be used for any others. For example, the following .htaccess file will disable globals, set the maximum file upload size to 20MB, and allow PHP scripts to run for 10 minutes (600 seconds):

php_flag register_globals off
php_value upload_max_filesize 20M
php_value max_execution_time 600

But please keep in mind it’s not working for all servers depends the server end restriction.


Posted in Linux-Apache-PHPComments (1)