Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to raise the PHP memory limit with .htaccess

This guide shows you how to give your PHP website more memory by adding one line to the .htaccess file.

How-To Guides2 min read12 steps

What is the PHP memory limit?

PHP is the language that runs many websites, such as WordPress. Each PHP page can only use a set amount of memory (the short-term space a computer uses while working). That cap is the memory limit.

If a page needs more than the cap, you may see an error like "Allowed memory size exhausted". Raising the limit can fix it.

The .htaccess file is a small settings file for the Apache web server. It sits in your website folder. The dot at the start means it is hidden by default.

Before you start

Back up your .htaccess file. A wrong line can make your site show a 500 error.

Steps

  1. Log in to your hosting control panel. The login details are in your Hostvento welcome email.
  2. Open File Manager.
  3. Go to your website folder. This is often called public_html.
  4. Turn on the option to show hidden files, if you cannot see .htaccess.
  5. Right-click .htaccess and choose Download to keep a backup copy.
  6. Right-click it again and choose Edit.
  7. Add this line at the very bottom:
php_value memory_limit 256M

This sets the limit to 256 megabytes. You can use another number, such as 128M or 512M.

  1. Click Save Changes.
  2. Reload your website to check that it still works.

If you get a 500 error

Some servers run PHP in a way that does not allow php_value in .htaccess. Your site then shows a 500 error.

  1. Open .htaccess again and delete the line you added.
  2. Save the file. Your site should work again.
  3. Use another method instead. Many control panels have a PHP settings page where you can change memory_limit. Or create a php.ini file with this line:
memory_limit = 256M

You can also ask Hostvento support to change it for you.

Tip: Do not set a huge number. Your hosting plan has its own top limit. Ask support what yours is.

Quick recap

  • The memory limit caps how much memory one PHP page can use.
  • Back up .htaccess first.
  • Add php_value memory_limit 256M at the bottom and save.
  • If the site shows a 500 error, remove the line and use php.ini or the PHP settings page instead.