The .htaccess file is an important configuration file on Apache servers (a type of web server software). The .htaccess file allows you to adjust/override the web server configuration, without the need to edit the server’s main configuration files.
How do you access the .htaccess file?
There are a few different methods to access the .htaccess file on your server:
- With a FTP or sFTP client
- Tip: Use a free & open-source FTP client such as FileZilla or CyberDuck
- With the File Manager in your webhosting control panel (such as cPanel, Plesk, or DirectAdmin)
Where is the .htaccess file located?
The .htaccess file is located in the root folder of your website. In most cases, this is the public_html folder.
Apache hides .htaccess files by default, therefore you may need to enable the “Show Hidden Files” option in the settings of the File Management tool that you’re using.
Changing permissions of the .htaccess file
File Permissions determine who is able to read, write and execute files on the server.
You can change file/folder permissions with an FTP client, or with the built-in File Manager in your webhosting software like cPanel.
The WordPress Codex recommends configuring 644 permissions for the .htaccess file.
Changing permissions of the .htaccess file with an FTP client
Navigate to the .htaccess file, right-click the file and select File permissions…
Navigate to the .htaccess file, Right-click the file and select Info.
Changing permissions of the .htaccess file within your webhosting software (such as cPanel/DirectAdmin)
Navigate to File Manager, browse to your .htaccess file and select it.
With the file selected, click Permissions in the top menu bar.
Navigate to File Manager, browse to your .htaccess file and enable the Select checkbox for this file.
Scroll down until you find the Set Permission button, enter the desired permissions in the field and click Set Permission to apply the change.
Editing the .htaccess file
Important: Before making changes to the .htaccess file, make sure to save a (local) back-up of the original file. By doing this, you will be able to revert your changes in case anything unexpected happens.
Locate the .htaccess file on your server, then open the file in any Text Editor to make the desired changes.
Implement your changes outside of the #Begin and #End Really Simple Security comments, or they will be stripped from the file.