Ask the community if you have any question about PHP,
MySQL, Apache and Linux for quick answers!!!

Archive for .htaccess

Setting a php.ini directive in .htaccess to apply only to one .php file

Yesterday I needed to increase the value of upload_max_filesize for a site's admin script/page while other pages of the size didn't require that. It is really easy to do it by using Apache's Files directive in .htaccess for a specific file with the below code.

<Files my.php>
php_value upload_max_filesize 10M
</Files>

Comments

How to remove PHPSESSID from URL?

You can remove PHPSESSID from URL by changing session.use_trans_sid value in php.ini, .htaccess (Apache) or in PHP code.

In php.ini set the value of session.use_trans_sid to 0
session.use_trans_sid = 0

In .htaccess
php_value session.use_trans_sid 0

In PHP code set the use_trans_sid value to false like below

ini_set('session.use_trans_sid', false);

Comments

Increasing file upload limit in PHP

There are different options to increase file upload limit in PHP. First is changing PHP configuration file (php.ini) and restarting webserver or overwriting the php.ini value in .htacces (this option is available if you are running Apache).

There are 2 directives which affect upload limit i.e. upload_max_filesize and post_max_size.

Now we look at the first method. First you have to find out where the php.ini is. To find out the location, make a .php file containing only this code and place it in your webroot and point your browser to this file.

< ?php phpinfo(); ?>

In the page output you can find Configuration File Path. Open this file and change the values for upload_max_filesize and post_max_size according to your requirement e.g. to set 10MB upload limit, the values will be
upload_max_filesize = 10M
post_max_size = 10M

Read the rest of this entry »

Comments

Enable register globals

It is strongly recommended that you do not turn on the register_globals. But if you still want to turn on register_globals then follow these steps

Make a .php file containing only this code

< ?php phpinfo(); ?>

And upload this file to your new server and open in the browser. In the page output find the value for 'register_globals'. If it is off, then you can solve this problem in the following ways

Read the rest of this entry »

Comments off