Htaccess files are hidden plain text files that are on the server to help control how your visitors interact with your website. The htaccess file is also used to block specific traffic from being able to view your website. If you look for your .htaccess file you’ll see that there’s no filename. The extension is .htaccess which tells the server what type of file it is. In cPanel you can see if you have a current .htaccess file using file manager but you will need to make sure you have selected to view hidden files. If you are not familiar with using file manager please read our article. To view hidden files in file manager, select the ‘file manager‘ icon in cPanel and make sure the box is checked next to ‘Show Hidden Files.’ Then click ‘OK‘ and you will be able to view hidden files.
What can I do with my .htaccess file?
You might have a private area of your website you wish to keep password protected. This password protection is actually set up in the .htaccess file. Most of the functions of the htaccess file, you do not have to concern yourself with as they will be automatically written through cPanel. This is the case of password protecting directories. While you set it up in cPanel, it actually writes a directive to your htaccess file.
Other functions of the htaccess file include, prohibiting hotlinks, rewriting URLs, setting default pages, creating redirects, reconfiguring account settings, and much more. It’s really important to realize how the htaccess file can affect your entire account. Changing something in the htaccess file can alter how your website functions so it’s really important BEFORE making changes to your htaccess to backup your current htaccess file.
If you are getting errors on your website, the .htaccess file can often be the culprit.
- This is easily tested by renaming your current htaccess file. Often, during troubleshooting I’ll simply rename the .htaccess to .htaccess.ops and now you can try reload the website. If the site loads I then know the issue resides in my configuration of the .htaccess file. If it does not fix the issue I was having, I’ll rename the htaccess by removing the .ops I added to the end. That way, it won’t affect my website after I resolve the issue.
- If you are not seeing a change in your PHP settings, you may have to make your php.ini file affect all child folders as well. This is referred to as making the file “recursive“.
This is a quick article with steps to show you where your account’s .htaccess file resides on the server, and how to edit it.
What exactly is .htaccess?
The .htaccess file is a hidden text file that allows you to control the way visitors are able to access your site. Some common uses of the .htaccess file would be restricting access to certain files, or redirecting URLs.
You can review our full .htaccess file reference list for more examples of what you can do with a .htaccess file.
Where can i find my .htaccess file?
By default you should have a .htaccess file created on your account in the following directory:
You can use your favorite FTP client to modify this file, or follow the steps below to access it directly from cPanel:
- Login to your cPanel.
- Under the Files section, click on File Manager.
- Locate your .htaccess file, you may have to show hidden files (click Settings–>Check the “Show Hidden Files (dotfiles)” box).
- Right-click on the .htaccess file and select Edit.
- If your .htaccess file didn’t exist already during the previous step, click on +File at the top-left, name the file .htaccess, and finally set the directory for the file to be created to /public_html/ or the document root of your site.
- You might have a text editor encoding dialog box pop-up, you can simply click on Edit.
Congratulations, now you know how to locate, and edit your .htaccess file!