This guide will show you exactly how to increase memory_limit using .htaccess in cPanel a fast, beginner-friendly method that works on most shared hosting platforms, including Hostrago.
If your website suddenly shows a “Fatal Error: Allowed memory size exhausted”, it’s time to act. This common error usually means your PHP scripts have hit the memory_limit set by your hosting provider.
The good news? You don’t need to be a developer or server expert to fix it.
What Does memory_limit
Do?
The memory_limit
in PHP controls how much memory a script is allowed to use. Think of it like a speed cap on a car too low, and your website struggles to run.
If you:
- Use WordPress with many plugins
- Run eCommerce platforms like WooCommerce or Magento
- Upload large images or process video
- Run backup or security plugins
How to Increase memory_limit Using .htaccess in cPanel in 3 Easy Steps
Let’s skip the complicated methods and focus on a simple fix through your .htaccess
file.
Step 1: Log in to cPanel
Head to your web hosting dashboard.
For Hostrago customers, visit:
Step 2: Find the .htaccess File
- In cPanel, go to File Manager

- Navigate to public_html (or your domain’s root directory)

- If you don’t see
.htaccess
, click Settings (top right) → Check Show Hidden Files
No file? Create a new file named .htaccess
.
Step 3: Edit the File
Add this line at the top or bottom of the .htaccess
file:
php_value memory_limit 512M
Save and close the file. Then refresh your site.
Bonus: Verify It’s Working
To confirm your new limit is active:
- Create a file named
info.php
with this content:
<?php phpinfo(); ?>
- 2. Upload it to your site and open
yourdomain.com/info.php
- 3. Search for
memory_limit
and check the value
Alternative Fix: Use MultiPHP INI Editor (If .htaccess Fails)
Some servers may not allow php_value
in .htaccess
. You’ll know this if your site gives a “500 Internal Server Error” after editing the file.
Solution:
- Go to Software > MultiPHP INI Editor in cPanel
- Choose your domain
- Set
memory_limit = 512M
or more - Click Apply
Real-World Scenarios
Here’s when raising memory_limit helps:
Scenario | Default Limit | Suggested Limit |
---|---|---|
WordPress with 5–10 plugins | 128M | 512M |
WooCommerce store | 256M | 768M–1024M |
Magento or Drupal sites | 256M | 1024M |
Sites with image or video uploads | 128M | 512M–1024M |
Final Words
Increasing your site’s memory limit doesn’t need to be a headache. With .htaccess
, it takes just 60 seconds and no coding experience. Now that you know how to increase memory_limit using .htaccess in cPanel, you’re ready to solve memory errors and enjoy smoother website performance.
Still stuck or want expert support? Contact Hostrago or explore our advanced hosting plans built for performance and control.