How to Find and Edit the Hidden File .htaccess to Add Directives to Your Website
Posted by Alex on 19 04 2017.
Hidden files, by default, is does not appear when you use cPanel’s File Manager tool. If you may not know yet, the hidden files in cPanel are the ones that begin with a dot, e.g. .htaccess, .htpasswd, and .bashrc files.
Hidden files are commonly edited. Thus, if you want to edit them through the File Manager, make sure you have the checkbox for it checked.
How do you show hidden files?
- Log in to cPanel using your account.
- Once you’re in, navigate to the Files section and open the File Manager tool.
- The File Manager Directory Selection will appear. Click the checkbox for the Show Hidden Files (dotfiles) setting.
- Click Go to implement the changes.
Normally, the Directory Selection window will pop up. If it doesn’t and you got in the File Manager and see no hidden files, the pop-up window must have been disabled. Clicking the Skip this question, and always open this directory in the future when opening the file manager option will do this.
To enable the pop up again:
- Refer to the bottom of your main cPanel screen.
- Click on Reset all interface settings. If you can’t find the said button, look for the Find search box and type ‘reset all’. Once it takes you to where you need to go, proceed with the step.
- Once you’re done, open your File Manager Tool once again.
- The procedure above is for the X3-themed cPanel.
If your cPanel’s using the Paper Lantern theme, the procedure will be a bit different.
- Inside the File Manager, refer to the top right corner.
- Once you’re there, click Settings.
- A pop-up will appear. Check Show Hidden Files (dotfiles).
- Click Save to save the settings.
Editing your .htaccess
The .htaccess file contains instructions or directives that tell the server how to act or behave in specific instances. It affects the way your website functions directly. These directives include redirects and rewriting URLS, which are two common ones.
Scripts like WordPress, Joomla, Drupal, and Magento add directives to the .htaccess file to help them work at all.
There can be other reasons to edit .htaccess at any point. However, we’ll teach you how to edit the file, not what to change in it. We will use the cPanel File Manager to do this.
Before proceeding, we highly encourage you to back up your website first so that you can revert back to the previous version if you don’t like the results of your actions.
How to edit .htaccess
- Login to cPanel using your account.
- Go to the Files section and click File Manager.
- Select Document Root for: and pick the domain name you want to access.
- Check the Show Hidden Files (dotfiles) checkbox.
- Click Go. This will open a new tab or window.
- Look for .htaccess in the list. Scroll down if you have to.
- Right-click on it and click Code Edit. A dialog box may show up to ask you about encoding. Click on the Edit button to proceed. A new window will appear.
- Edit the file according to your preference.
- Go to the upper right corner and click the Save Changes button to finish.
- Test your website to see if the desired effect manifests. Otherwise, fix the error or just revert back to your previous version until you have your site fixed.
- Once complete, click Close.