{"id":478,"date":"2012-11-15T15:31:28","date_gmt":"2012-11-15T15:31:28","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2012\/11\/15\/htaccess-prevent-access\/"},"modified":"2021-08-16T23:29:13","modified_gmt":"2021-08-17T03:29:13","slug":"htaccess-prevent-access","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/","title":{"rendered":"How to prevent access to a specific file in htaccess"},"content":{"rendered":"<p>The .<em>htaccess<\/em> 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.<\/p>\n<p>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.<\/p>\n<p><strong>Preventing access to certain files via htaccess<\/strong><\/p>\n<ol class=\"article_list\">\n<li>First, you will need to <a href=\"\/support\/edu\/cpanel\/how-to-log-into-cpanel\/\">log into your cPanel<\/a> to access the htaccess file.<\/li>\n<li>Find the <strong>Files <\/strong>category and click on the <strong>File Manager<\/strong> icon.<br>\n<a href=\"\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png\" rel=\"lightbox-0\"><img decoding=\"async\" width=\"929\" height=\"750\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png\" class=\"optimized-lcp-image\" alt=\"cpanel\" loading=\"eager\" fetchpriority=\"high\" sizes=\"(max-width: 768px) 100vw, 768px\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png 929w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel-300x242.png 300w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel-768x620.png 768w\"><\/a>\n<div style=\"clear:both;\"><\/div>\n<\/li>\n<li>In order to select a different domain click on the <strong>Settings<\/strong> 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 <strong>Show Hidden Files<\/strong> is checked. Click the <strong>Save<\/strong> button to enter the <em>File Manager<\/em>.<br>\n<a href=\"\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-settings.png\" rel=\"lightbox-0\"><img loading=\"lazy\" decoding=\"async\" alt=\"file-manager-show-hidden\" class=\"std_ss size-full wp-image-5730\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-settings.png\" width=\"374\" height=\"244\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-settings.png 374w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-settings-300x196.png 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/a>\n<div style=\"clear:both;\"><\/div>\n<\/li>\n<li>You should now be in the root folder of the domain you chose. Look for the <em>.htaccess<\/em> file and right click on it. This brings up a menu. Find and click on the <strong>Edit <\/strong>option. If you get a popup box, simply find and click the <strong>Edit <\/strong>button in the lower right corner to continue to the editor.<br>\n<a href=\"\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-htaccess-file.png\" rel=\"lightbox-0\"><img loading=\"lazy\" decoding=\"async\" alt=\"file-manager-htaccess\" class=\"std_ss size-full wp-image-5731\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-htaccess-file.png\" width=\"714\" height=\"365\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-htaccess-file.png 714w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-htaccess-file-300x153.png 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/a>\n<div style=\"clear:both;\"><\/div>\n<\/li>\n<li>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.)<br>\n<code># the following prevents display of the filetohide file<br>\n&lt;files filetohide.jpg&gt;<br>\norder allow,deny<br>\ndeny from all<br>\n&lt;\/files&gt;<\/code><\/li>\n<li>Be sure to hit the <strong>Save Changes<\/strong> button in the upper right corner to save your new htaccess configuration.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>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<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/\"> Read More ><\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4288],"tags":[],"class_list":["post-478","post","type-post","status-publish","format-standard","hentry","category-website"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to prevent access to a specific file in htaccess | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Learn to restrict access to specific files in this htaccess tutorial.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to prevent access to a specific file in htaccess | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Learn to restrict access to specific files in this htaccess tutorial.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-15T15:31:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T03:29:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png\" \/>\n<meta name=\"author\" content=\"Scott Mitchell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Scott Mitchell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/\"},\"author\":{\"name\":\"Scott Mitchell\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\"},\"headline\":\"How to prevent access to a specific file in htaccess\",\"datePublished\":\"2012-11-15T15:31:28+00:00\",\"dateModified\":\"2021-08-17T03:29:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/\"},\"wordCount\":329,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png\",\"articleSection\":[\"Website\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/\",\"name\":\"How to prevent access to a specific file in htaccess | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png\",\"datePublished\":\"2012-11-15T15:31:28+00:00\",\"dateModified\":\"2021-08-17T03:29:13+00:00\",\"description\":\"Learn to restrict access to specific files in this htaccess tutorial.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#primaryimage\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png\",\"width\":929,\"height\":750,\"caption\":\"cpanel\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to prevent access to a specific file in htaccess\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed\",\"name\":\"Scott Mitchell\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to prevent access to a specific file in htaccess | InMotion Hosting","description":"Learn to restrict access to specific files in this htaccess tutorial.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/","og_locale":"en_US","og_type":"article","og_title":"How to prevent access to a specific file in htaccess | InMotion Hosting","og_description":"Learn to restrict access to specific files in this htaccess tutorial.","og_url":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2012-11-15T15:31:28+00:00","article_modified_time":"2021-08-17T03:29:13+00:00","og_image":[{"url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png","type":"","width":"","height":""}],"author":"Scott Mitchell","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Scott Mitchell","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/"},"author":{"name":"Scott Mitchell","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed"},"headline":"How to prevent access to a specific file in htaccess","datePublished":"2012-11-15T15:31:28+00:00","dateModified":"2021-08-17T03:29:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/"},"wordCount":329,"commentCount":6,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png","articleSection":["Website"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/","url":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/","name":"How to prevent access to a specific file in htaccess | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#primaryimage"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png","datePublished":"2012-11-15T15:31:28+00:00","dateModified":"2021-08-17T03:29:13+00:00","description":"Learn to restrict access to specific files in this htaccess tutorial.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#primaryimage","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/edu_htaccess_select-cpanel.png","width":929,"height":750,"caption":"cpanel"},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/htaccess-prevent-access\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to prevent access to a specific file in htaccess"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/d850efb28ef3573db7d24b0d8fa9eaed","name":"Scott Mitchell","url":"https:\/\/www.inmotionhosting.com\/support\/author\/scott\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=478"}],"version-history":[{"count":4,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/478\/revisions"}],"predecessor-version":[{"id":85311,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/478\/revisions\/85311"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}