InMotion Hosting Support Center

The .htaccess file is a hidden text file within your hosting account that can be very powerful. It is designed so that you can modify it to change the behavior of your website that normally would take higher access beyond your account. It acts as a liaison between your domain and the server and can perform many functions.

There may be times when you want to restrict direct access to specific files that reside in your account. The server itself will still be able to access the file and use the information. This can be done via the htaccess file. Below are the instructions for preventing access to specific files via the .htaccess file.

Preventing access to certain files via htaccess

  1. First, you will need to log into your cPanel to access the htaccess file.
  2. Find the Files category and click on the File Manager icon.
  3. In order to select a different domain click on the Settings in the top right corner. For addon domains, click on the dropdown and find your desired addon domain name. Be sure the checkbox next to Show Hidden Files is checked. Click the Save button to enter the File Manager.
  4. You should now be in the root folder of the domain you chose. Look for the .htaccess file and right click on it. This brings up a menu. Find and click on the Edit option. If you get a popup box, simply find and click the Edit button in the lower right corner to continue to the editor.
  5. You are now in the htaccess editor. Paste the following code in the file to prevent access to your selected file. In our example below, we decided to hide the file named filetohide.jpg. This can be a file of any tyep (html, jpg, php, etc.)
    # the following prevents display of the filetohide file
    <files filetohide.jpg>
    order allow,deny
    deny from all
  6. Be sure to hit the Save Changes button in the upper right corner to save your new htaccess configuration.
Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

n/a Points
2018-08-09 10:26 am

I want to hide my sitemap from competitors. not for search engines. Is it possible above-mentioned .htaccess tutorial? Please help me with this to enhance the developer's knowledge.

609 Points
2018-08-09 3:19 pm
You could try renaming the file to something difficult to guess and submitting it to search engines afterwards. You can see other options within this Stack Exchange forum. I hope this proves helpful for you.
n/a Points
2017-04-03 9:03 pm

This was a great article, learned alot! Thanks!!

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

3 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!