Our Help Portal

Troubleshooting Support Articles
Searchable Help Information Repository
Self-Service Resources How-Tos
Technical Customer Walkthroughs   Browse All Knowledge ! ....

Get Prices Learn More


< All Topics

How to set the PHP script memory limit in a .htaccess file?

To set the PHP script memory limit using a .htaccess file, you can use the php_value directive. Follow these steps:

  • Create or Edit .htaccess File:
    • Using a text editor, create a new file named .htaccess if you don’t have one in your website’s root directory. If you already have one, you can edit it.
  • Add Memory Limit Configuration:
    • Add the following lines to your .htaccess file to set the PHP script memory limit. Adjust the value of 128M to your desired memory limit.

<IfModule mod_php5.c>
php_value memory_limit 128M

If you’re using PHP as a FastCGI application, you can use the following:

<IfModule mod_fcgid.c>
FcgidWrapper “php-cgi .php” .php
php_value memory_limit 128M

  • Save and Upload:
    • Save the changes to the .htaccess file and upload it to your website’s root directory using FTP or your hosting file manager.
  • Verify the Changes:
    • To confirm that the memory limit has been set, you can create a PHP file (e.g., phpinfo.php) in your web directory with the following content:


  • Open this file in your browser and search for “memory_limit” to see if the new limit is reflected.

Please note that not all hosting environments allow you to modify PHP settings via .htaccess, and some hosting providers may have restrictions in place. If you encounter issues or if your changes don’t take effect, you may need to contact your hosting support for assistance or use alternative methods to modify PHP configuration, depending on your hosting environment.