Help Docs Software Kadence Kadence Solid Kadence Solid References Editing and handling the .htaccess file

Editing and handling the .htaccess file

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.

Was this article helpful?