How to Edit htaccess File in WordPress?

htaccess is a configuration file for web servers running with Apache software. It contains server configurations to direct the behavior your website. The file by default has no name and only contains .htaccess extension. This file contains the configuration on each directory level. Therefore, you can control each directory on your server with different directives.

How to Edit the File?

WordPress by default adds the permalink structure in your htaccess file. There are many reasons you need to add parameters in .htaccess configuration file. One good example is to redirect one page on your WordPress site to another page or another site on the same server. Unlike functions.php and other theme’s files, you can’t edit .htaccess file from your WordPress administrator panel. You have the following two options:

  1. Use File Manager app in your hosting account
  2. Use FTP to remotely edit server files

Edit .htaccess with File Manager

  • Login to your hosting account.
  • Depending upon the setup you can go to cPanel or any other custom option available on your server.
  • Find File Manager app and open it.
  • Locate .htaccess file in your root installation.
  • Click “Edit” button to modify the file.
  • Add your code and save the changes.
  • Upload the file back to the server.

Edit .htaccess Using FTP

  • Login to your hosting using your favorite FTP client like FileZilla.
  • Navigate to your WordPress site’s root installation folder.
  • Find .htaccess file, right click on it and choose “Edit” option.
  • Update the code in the file.
  • Save the changes to upload the file back to the server.

Note:

  1. You can create .htaccess file for each folder on your site. If there is no .htaccess in the subdirectory then it will inherit the controls from the parent directory.
  2. If you do not see the file, make sure to enable “View Hidden Files” option in your operating system as well in the FTP client.
  3. Some plugins like Yoast SEO allows you to edit .htaccess file from administrator panel.

Leave a Comment