Home » Php » php – Set Memory Limit in htaccess

php – Set Memory Limit in htaccess

Posted by: admin April 23, 2020 Leave a comment


I am working on word press. I need to increase the memory so added the following line to my htaccess file

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

php_value memory_limit 64M

my sample php page

but it throws the 500 internal server error. what is the problem here..

How to&Answers:

In your .htaccess you can add:

PHP 5.x

<IfModule mod_php5.c>
    php_value memory_limit 64M

PHP 7.x

<IfModule mod_php7.c>
    php_value memory_limit 64M

If page breaks again, then you are using PHP as mod_php in apache, but error is due to something else.

If page does not break, then you are using PHP as CGI module and therefore cannot use php values – in the link I’ve provided might be solution but I’m not sure you will be able to apply it.

Read more on http://support.tigertech.net/php-value