How to Configure WordPress .htaccess Rules Using cPanel File Manager

How to Configure WordPress .htaccess Rules Using cPanel File Manager

How to Configure WordPress .htaccess Rules Using cPanel File Manager

How to Configure WordPress .htaccess Rules Using cPanel File Manager

Step-by-step tutorial by Hiverift

🧾 What is the .htaccess File?

The .htaccess file is a hidden configuration file used by Apache web servers to control settings like redirects, security, permalinks, and more. In WordPress, it’s essential for SEO-friendly URLs and performance tweaks.

🔧 Step-by-Step: Edit .htaccess via cPanel

Step 1: Log into cPanel

  • Visit yourdomain.com/cpanel
  • Enter your hosting username and password

Step 2: Open File Manager

  • Scroll to the Files section
  • Click on File Manager
  • Navigate to public_html (or the root folder of your WordPress site)
Note: Make sure hidden files are visible by clicking Settings (top-right corner) and checking “Show Hidden Files (dotfiles)”.

Step 3: Locate or Create .htaccess

  • Look for the file named .htaccess
  • If it doesn’t exist, click + File → Name it .htaccess

Step 4: Edit the .htaccess File

  • Right-click .htaccess → Click Edit
  • Confirm any encoding prompts and begin editing
Always back up your .htaccess file before making changes.

✅ Default WordPress .htaccess Rules

# 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>
# END WordPress

🛡 Useful Custom .htaccess Snippets

🔒 Block XML-RPC Attacks

<Files xmlrpc.php>
Order Deny,Allow
Deny from all
</Files>

🚀 Enable Browser Caching

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
</IfModule>

🔁 Redirect HTTP to HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Use redirects carefully. A single mistake can break site access.

🧹 How to Reset .htaccess

  1. Delete current .htaccess (or rename to .htaccess.bak)
  2. Log in to your WordPress dashboard
  3. Go to Settings → Permalinks and click Save Changes
  4. This will regenerate the default .htaccess rules

✅ Final Thoughts

The .htaccess file is a powerful tool for managing WordPress behavior, performance, and security. Always take backups and test after editing to avoid site crashes.

 

Post Your Comment

Build Your Website with HiveRift

From professional business to enterprise, we’ve got you covered!

©2025, Hosting. All Rights Reserved by KhatuShyam Technologies

HiveRift
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.