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.
Why Use .htaccess for PHP Settings?
-
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.
Steps to Create a Custom .htaccess File
Step 1: Access Your Hosting Account
-
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).
Step 2: Create or Edit .htaccess
-
If
.htaccessalready exists, open it for editing. -
If not, create a new file named
.htaccess.
Step 3: Add PHP Directives
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
Step 4: Save and Test
-
Save the
.htaccessfile. -
Create a test file
info.phpwith:<?php phpinfo(); ?> -
Load it in your browser to confirm the new settings.
-
Delete the test file afterward for security.
Important Notes
|