Skip to content
  • Pricing
  • Products & Services
      Save 25%

      Solid Suite

      Secure your sites, keep them safely backed up, and grow your business… all while saving time and money.

      • Solid Security
      • Solid Backups
      • Solid Central
      • Solid Academy
      See pricing

      Protect

      Shield your site from cyberattacks and prevent security vulnerabilities

      A cloud-first solution for rocket fast backups and one-click restore.

      Repair

      Hacked website? Let our WordPress security experts clean up malicious code, remove threats and restore your site.

      Manage

      Maximize and amplify your admin with remote multi-site management.

      Ensure delivery of every email sent from your site.

      Free Plugins

  • Resources
      Save 25%

      Solid Suite

      Secure your sites, keep them safely backed up, and grow your business… all while saving time and money.

      • Solid Security
      • Solid Backups
      • Solid Central
      • Solid Academy
      See pricing

      Academy

      Solid Academy

      For anyone who wants to start or grow a business around WordPress.

      Guides

      Dive deeper into our free WordPress and business guides.

      Livestreams

      Free livestreams to help you discover new tools and work more efficiently

      Tutorials Academy

      Learn WordPress with our beginner WordPress tutorials

      Resources

      Blog

      Catch up on the latest news from our WordPress security experts

      Vulnerability Report

      Keep track of every new plugin and theme vulnerability

      Support

      Your success with Security, Backups and Central is our highest priority.

      Documentation

      Learn everything you need to know about our products & services.

Sign In Get Solid Suite
SolidWP Logo Black
  • Pricing
  • Products & Services
    • Solid Security Pro
    • Solid Backups — NextGen
    • Solid Fix
    • Solid Central
    • Free Plugins
    • Solid Security
    • Solid Performance
    • Solid Mail
  • Resources
    • Solid Academy
    • Guides
    • Livestreams
    • Tutorials
    • Blog
    • Vulnerability Report
    • Support
    • Documentation

Learn More

10
  • Clearing caches and transients in WordPress
  • Editing and handling the .htaccess file
  • Installing Downloaded Plugins in WordPress
  • Understanding PHP’s memory limit
  • Understanding PHP’s max_execution_time
  • Help! My Site’s Been Hacked!
  • How To Use WP DEBUG To Isolate Issues
  • Translation in WordPress
  • Editing and handling wp-config.php
  • Understanding Email Deliverability in WordPress
View Categories
  • Home
  • SolidWP Documentation
  • General WordPress
  • Learn More
  • Editing and handling the .htaccess file

Editing and handling the .htaccess file

4 min read

Why modify the .htaccess file? #

The .htaccess file lets you control how Apache serves your WordPress site—redirects, permalinks, security rules, caching headers, and more. Modifying it can unlock powerful configuration options, but a small mistake can render your site inaccessible. This guide shows how to safely edit .htaccess using common hosting tools.

What is the .htaccess file? #

.htaccess is a plain-text configuration file placed in a site’s directory (often the “root” or public_html folder). Apache reads it on every request and applies the directives it contains. In a WordPress environment, it typically handles “pretty” permalinks and may include security or performance rules.

Before you edit #

  1. Make a backup
    Always download a copy of the existing .htaccess file before making changes. If anything goes wrong, you can restore the original and avoid downtime.
  2. Use a code-friendly editor
    Edit with a plain-text editor (e.g., Sublime Text, VS Code, Notepad). Avoid word processors like Microsoft Word or Google Docs, which can insert hidden formatting.
  3. Check file visibility
    By default, .htaccess is hidden. Ensure your FTP client or control panel is set to show hidden files.
  4. Test immediately
    After saving changes, load your site in a browser. If you see a “500 Internal Server Error,” revert to the backup and inspect for syntax errors.

Where is the .htaccess file? #

  • In most setups, it lives in the root directory (the same location as wp-config.php).
  • If WordPress is installed in a subdirectory (e.g., /blog), look there.
  • If no .htaccess exists, WordPress will generate one when you save your permalink settings—then you can download and edit that new file.

How to edit .htaccess via FTP/SFTP #

  1. Obtain credentials
    • Hostname, username, password (and port for SFTP).
    • If in doubt, request them from your hosting provider.
  2. Connect with an FTP/SFTP client
    • Recommended: FileZilla or any SFTP-capable client.
    • Enter credentials and connect.
  3. Show hidden files
    • In FileZilla: go to Server ? Force showing hidden files.
    • In other clients: check preferences for “show dotfiles.”
  4. Locate the file
    • Navigate to your site’s root (often public_html, www, or the folder named after your domain).
    • Right-click .htaccess and select Download.
  5. Edit and upload
    • Open the downloaded file in your editor.
    • Make the desired changes, save, then drag the updated file back to the server—confirming “Overwrite.”

How to edit .htaccess via cPanel #

  1. Log in to your hosting account and open cPanel.
  2. Select File Manager.
  3. In File Manager, click Settings (top right) and enable Show Hidden Files (dotfiles).
  4. Navigate to your site’s root folder (e.g., public_html).
  5. Right-click .htaccess and choose Download (or Edit for in-line editing).
  6. If downloaded, edit locally and then use Upload to replace the file. If editing in-line, make changes and click Save Changes.

How to edit .htaccess via Plesk #

  1. Log in to Plesk and go to Websites & Domains.
  2. Click File Manager for your domain.
  3. Click the gear icon or Settings, then enable Show Hidden Files.
  4. Locate the .htaccess file in the domain’s root directory.
  5. Select it and choose Download or Edit in Text Editor.
  6. After editing locally, upload the revised file; if in-editor, save directly.

How to edit .htaccess via DirectAdmin #

  1. Log in to DirectAdmin and click File Manager.
  2. Click Options (top right) and tick Show Hidden Files.
  3. Open the folder for your website (e.g., public_html).
  4. Locate .htaccess and use Download to edit locally or Edit for in-browser changes.
  5. Upload the edited file or save changes in the editor.

Things to know about editing the .htaccess file #

  • Syntax matters
    Missing a single character (e.g., a space, slash, or < bracket) can cause a “500 Internal Server Error.”
  • Order of directives
    Apache processes rules top-to-bottom. Place redirects before WordPress’s own rewrite block if you want them to run first.
  • Backup plugin
    Leverage a reliable backup solution (for example, Solid Backups — NextGen) to create a backup before making changes.
  • File permissions
    After uploading, ensure .htaccess retains a permission of 644 (owner read/write; group/world read).
  • Testing environment
    Whenever possible, make changes in a staging site to catch errors before affecting live users.

Be sure to preserve this section of the .htaccess file:

# 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

as it is needed for WordPress to function correctly.

Updated on April 28, 2025

Was this doc helpful?

  • Happy
  • Normal
  • Sad
Installing Downloaded Plugins in WordPress
Table of Contents
  • Why modify the .htaccess file?
  • What is the .htaccess file?
  • Before you edit
  • Where is the .htaccess file?
  • How to edit .htaccess via FTP/SFTP
  • How to edit .htaccess via cPanel
  • How to edit .htaccess via Plesk
  • How to edit .htaccess via DirectAdmin
  • Things to know about editing the .htaccess file
SolidWP
  • Pricing
  • Products
    • Solid Suite – save 25%
    • Solid Security
    • Solid Backups — NextGen
    • Solid Central Pro
  • Resources
    • Blog
    • Academy
    • Guides
    • Tutorials
    • Vulnerability report
  • Support
    • Documentation
  • My account
  • Contact us
    • Terms
    • Refund policy
    • Privacy policy
  • About SolidWP
    • FAQ
    • Looking for iThemes?
    • Affiliates
    • Press
  • Our Partner Brands
    • GiveWP
    • Iconic
    • KadenceWP
    • LearnDash
    • MemberDash
    • Orderable
    • The Events Calendar

Get Solid Suite bundled with hosting.

Explore StellarSites
  • X
  • YouTube
  • Facebook

A Liquid Web Brand
Hosting for WordPress
© 2025 All Rights Reserved

StellarWP logo
Liquid Web logo