Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Memory Limit in htaccess [closed]

Tags:

php

.htaccess

I am working on WordPress. I need to increase the memory, so I 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]
</IfModule>

php_value memory_limit 64M

my sample php page

<?php
phpinfo(); 

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

like image 583
Codesen Avatar asked Aug 29 '12 07:08

Codesen


People also ask

How do I set the htaccess memory limit?

In case you have a . htaccess file, you can simply add the command: php_value memory_limit XM in it, to increase the memory limit to X MB.

How can I limit my PHP memory?

You can check it from your php. ini file. Execute php -i | grep "php. ini" on command line and check memory_limit in your Loaded Configuration File.


1 Answers

In your .htaccess you can add:

PHP 5.x

<IfModule mod_php5.c>
    php_value memory_limit 64M
</IfModule>

PHP 7.x

<IfModule mod_php7.c>
    php_value memory_limit 64M
</IfModule>

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

like image 75
Ivan Hušnjak Avatar answered Oct 19 '22 06:10

Ivan Hušnjak