In this article I quickly show you where your account’s .htaccess file resides on the server, as well as how to edit it.
You can make similar changes in the Apache configuration file, but only with root access. That’s why the .htaccess file is very important to users on our Linux Shared Hosting accounts.
What is .htaccess?
The .htaccess file is a hidden text file that allows you to control the way visitors 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 is my .htaccess file?
By default you should have a .htaccess file created on your account in the following directory:
/home/userna5/public_html/.htaccess
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 you didn’t locate your .htaccess file during the previous step, click on +File on 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!
Did you find this guide helpful? When you’re an InMotion Web Hosting customer, you get full access to the vast library of our support documentation as well as world-class, 24/7 support.
Thanks for this useful answer. But I still wonder why there are so many, .htaccess files and who creates this
.htaccess files may be automatically created by existing applications, or by people adding code for different purposes. So, if you’re using a few plugins for your website, it is possible that code is being added to the .htaccess files. I hope that helps to provide some clarity on the issue.
If you have any further questions or comments, please let us know.
I have found several htaccess files throughout my web site. The site has gone through several formats over the past 8 years. To effectively utilize my forced https code insertion into a default htaccess file, where do I place it in the root? Directly into the /public_html/? Is it then safe to delete all of the other htaccess files I find scattered throughout the site or are those issuing directives for plugins? One of them has some Leverage Browser Caching Ninja code inserted to set peramiters for the Caching Ninja plugin. Of which I am not so sure does anything.
Typically, you would put the .htaccess in the root directory of the website, but it can inherit rules from “parent” folders. It is difficult to say if you need the other .haccess files, since your website may rely on existing rules. Also, if you are using a CMS such as WordPress, Joomla, Drupal, etc. I recommend using a plugin, addon or extension instead of adding a rule directly to the .htaccess file. This is because CMS’ rely on .htaccess rules too and custom coded rules can interfere with their functionality.
Thank you,
John-Paul
super easy and super useful.
Thank you!
If we have (Windows with) MS-IIS?
IIS (ASP) does not use an .htaccess file by default. You can often accomplish similar tasks with the IIS Security options.
Thank you,
John-Paul
Omg, thank you so much.
.htaccess not supprt to nginx
Hello Yogesh,
Thank you for contacting us. Yes, your .htaccess rules must be translated to work with nginx.
There are many online tools available that can help you with that, as described in this post I found online.
Thank you,
John-Paul
great!!
Greate tips . i appriciate thank you boss
You Desere a salute….I was wandering since last 3 days…and you did the miracle by simpliying this.
Thanks
Works perfectly for host monster 🙂
I think the article was the best it can be. Thanks!
first of all thank you so much,
you are did a great job with your suggestion..
No improvement needed
Its just right. up to the point.