Skip to content

Setting up custom .htaccess files for PHP settings

The .htaccess file is a configuration file used by Apache web servers to override default settings. On ruachost.com, you can use .htaccess files to customize PHP directives without editing the global php.ini.

  • Apply PHP configuration changes per directory.
  • Override default limits (memory, upload size, execution time).
  • Enable or disable specific PHP features.
  • Useful when you don’t have direct access to the server’s global php.ini.
  • Log in to cPanel or use FTP/File Manager.
  • Navigate to the directory where you want to apply custom PHP settings (e.g., /public_html).
  1. If .htaccess already exists, open it for editing.
  2. If not, create a new file named .htaccess.

Insert the desired PHP settings using php_value or php_flag. Examples:

# Increase memory limit
php_value memory_limit 256M
# Increase maximum upload size
php_value upload_max_filesize 64M
php_value post_max_size 64M
# Increase script execution time
php_value max_execution_time 120
# Enable error display (development only)
php_flag display_errors On
# Disable error display (production)
php_flag display_errors Off
  • Save the .htaccess file.

  • Create a test file info.php with:

    <?php phpinfo(); ?>
  • Load it in your browser to confirm the new settings.

  • Delete the test file afterward for security.