Tips,Ideas, Free scripts and more…
Magic with htaccess file – Increase execution time, session expiry time and file upload size limit
<IfModule mod_php5.c>
php_value post_max_size 5M
php_value upload_max_filesize 5M
php_value memory_limit 300M
php_value max_execution_time 259200
php_value max_input_time 259200
php_value session.gc_maxlifetime 1200
</IfModule>
php_value memory_limit 300M – Set higher default php_value memory_limit in .htaccess
upload_max_filesize 5M - it increases default upload limit. The default upload limit is 2MB. the above htaccess increase increases file limit 2mb to 5 mb
php_value max_execution_time:
Set the number of seconds a script is allowed to run. If this is reached,
the script returns a fatal error. The default limit is 30 seconds or, if it
exists, the max_execution_time value defined in the configuration file. If
seconds is set to zero, no time limit is imposed.
php_value session.gc_maxlifetime:
The session.gc_maxlifetime only sets the age of the session files that will be deleted when
garbage collection runs.
If you have a busy web site with a lot of sessions being created, garbage collection will
run based on session.gc_probability/session.gc_divisor. Despite this being called
“probability” I tested this and it is strictly a count. Using the default
gc_probability/gc_divisor of 1/100, this means that garbage collection will run every 100
new sessions (Edit: Actually this occurs within the session_start() coding and would count
re-started sessions as well) and delete any existing session files that are older than the
session.gc_maxlifetime. There is no file locking on the session files, so active session
files will be deleted and things like users getting logged out will occur.
If this is on shared hosting and the session files are all kept in the default location and
someone else is using a smaller session.gc_maxlifetime or a more frequent
gc_probability/gc_divisor, then any of the session files will get deleted based on the
lowest value of gc_maxlifetime and the most frequent gc_probability/gc_divisor.
You need to increase session.gc_maxlifetime or make session.gc_divisor larger and if this is
on shared hosting, set session.save_path to be a location within your web space.
| Print article | This entry was posted by Raja MM on September 22, 2008 at 1:38 pm, and is filed under htaccess, server configuration. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |













about 1 year ago
This was exactly what I needed to solve a file upload limitation in WordPress 2.7. Thanks so much for the excellent articles on .htaccess and file upload limitations.
about 1 year ago
This was excellent, but I need some thing else
can you post “HOW TO LIMIT SESSION AUTHENTICATION TO ONLY ONE AT THE SAME TIME.”
using .htacess to authenticate.
Regards
Banwari
about 1 year ago
BanwariLal: Hope, this will help you..
http://www.addedbytes.com/apache/password-protect-a-directory-with-htaccess/
about 1 year ago
Hi,
I want to increase the time for files on the upload server from one day to seven days for NAVT.
Please let us know
about 2 months ago
Do you know of anyway with htaccess to disable someone from using your domain to point to their own website on the same server? Ex: they use YOURDOMAIN.com to promote their PHISHING WEBSITE.COM by using this simple URL to send users : YOURDOMAIN.COM/~phishing/file.html
Any help would be greatly appreciated. Thanks
about 2 months ago
Please check this “http://www.clockwatchers.com/htaccess_block.html”
Other suggestions,
1. if they are using your server for phishing, then please change your cpanel and ftp password.
2. Don’t save your password anywhere.
3. Some web hosting server provides an option to block ip’s, please check it.