{"id":46,"date":"2025-12-16T11:44:30","date_gmt":"2025-12-16T10:44:30","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=46"},"modified":"2026-01-27T09:25:15","modified_gmt":"2026-01-27T08:25:15","slug":"htaccess-file","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/","title":{"rendered":".htaccess file"},"content":{"rendered":"\n<div class=\"translation-block translation-block-merged\">\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#What_is_a_htaccess_file\" >What is a .htaccess file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#Why_a_period_at_the_beginning_of_a_file_name\" >Why a period at the beginning of a file name?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#What_we_use_the_htaccess_file_for_most_often\" >What we use the .htaccess file for most often<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#Custom_error_pages\" >Custom error pages<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#Website_start_page\" >Website start page<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#View_a_list_of_files\" >View a list of files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#Change_the_address_of_pages\" >Change the address of pages<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#Block_resource_hotlinking\" >Block resource hotlinking<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/htaccess-file\/#Password_protection_of_the_directory\" >Password protection of the directory<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_a_htaccess_file\"><\/span>What is a .htaccess file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original idea behind the .htaccess file, as its name suggests, was to control access to the directories of the folder in which it is located. Currently, it is mainly used to override parameters included by default in the server configuration, for example, PHP settings and to indicate the use of rules by web page scripts, the purpose of which will be, for example, to rewrite links into a readable and easy-to-remember form.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>It should be remembered that the .htaccess file and the values contained in it work both for files in the directory in which it is located, but also for all files located in subsequent directories in the structure. This happens until another .htaccess file is found in a given directory located lower in the structure and revokes\/changes the rules set in the current one above.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/\n\u251c\u2500\u2500 your-files\/\n\u251c\u2500\u2500 domain.com\/\n\u2502   \u251c\u2500\u2500 awstats\/\n\u2502   \u251c\u2500\u2500 public_html\/\n\u2502        \u251c\u2500\u2500 .htaccess (includes folders and directories in public_html)\n\u2502        \u251c\u2500\u2500 pictures\/\n\u2502        \u251c\u2500\u2500 style\/\n\u2502        \u2514\u2500\u2500 files\/\n\u2502             \u251c\u2500\u2500 .htaccess (overwrites the rules from the file located in public_html)\n\u2502             \u251c\u2500\u2500 directory1\/\n\u2502             \u2514\u2500\u2500 directory2\/<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_a_period_at_the_beginning_of_a_file_name\"><\/span>Why a period at the beginning of a file name?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<\/div>\n\n<div id=\"mybox-522238031\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Early access<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Still need help?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contact our customer service team.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Message us<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">In Linux systems, which are the basis of most servers running on the Internet, a dot at the beginning of a file or directory means that it is to be a hidden element. Therefore, very often when connecting via FTP to the server, the .htaccess file is not visible. Then you should make sure that in the settings of the file list and directories view in the FTP client application (e.g. FileZilla &#8211; information on how to configure the application can be found <a href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/configuring-filezilla-client-3-5-3\/\">HERE)<\/a> you have the option to show hidden items active.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_we_use_the_htaccess_file_for_most_often\"><\/span>What we use the .htaccess file for most often<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The .htaccess file, as we mentioned at the beginning, is mainly used to change server configuration parameters and set link rewrite rules, so you can use it, for m.in example, in the following situations:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Custom_error_pages\"><\/span>Custom error pages<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the event that the web server cannot fulfill the user&#8217;s request for various reasons, an error message is generated instead of the target page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The list of errors reported by our system with their descriptions can be found under HTTP Errors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With the help of the .htaccess file, we can define our own, independent of the system, pages explaining the situation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To do this, we create a folder called \/error-pages\/ inside the public_html directory of our website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In it, we place files with our own content displayed in the event of an error being generated, saving them as<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;error_code.php&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">for example.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>403.php<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">for the No Access message.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We also create a .htaccess file inside the directory with our error pages with the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Allow from all \nSatisfy Any<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The next step will be to create a .htaccess file inside the public_html directory with the following syntax for each of the errors:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ErrorDocument &lt;error_code&gt; \/error-pages\/&lt;error_code&gt;.php<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">for example.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ErrorDocument 401 \/error-pages\/401.php \nErrorDocument 403 \/error-pages\/403.php \nErrorDocument 404 \/error-pages\/404.php<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, after the server generates an exception, the page prepared by us will be displayed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Website_start_page\"><\/span>Website start page<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The full URL consists of the domain name (1), the name of the individual folders (2) and the name of the target file (3), e.g.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">www.mybox.com\/file\/test.zip<br>(1) (2) (3)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, if the last part is not defined, the web server searches the specified directory in an attempt to find the file displayed by default in such a situation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On our servers, the following values are automatically set as such names:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>index.htm index.html index.cgi index.pl index.php index.php5 index.xhtml<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To set your own list or order of files as start pages, add the following directive to the .htaccess file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DirectoryIndex &lt;file names separated by a single space&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For example.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DirectoryIndex index.html index.htm web.php index.php<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"lista-plikow\"><span class=\"ez-toc-section\" id=\"View_a_list_of_files\"><\/span>View a list of files<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default, listing files is blocked. If you want to display a list of files with all the contents of the current directory after calling a directory where there is no index.html or index.php file, you can add the following line in the .htaccess file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Options +Indexes<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Change_the_address_of_pages\"><\/span>Change the address of pages<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes it is necessary to change the address of some part of the website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, a sales page will move from a www.company.mybox.com\/commercial\/ domain to www.commercial.company.mybox.com<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In such a situation, Internet users using the old address should be redirected to the new one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To do this, you need to create a .htaccess file in the old content folder with the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Redirect &lt;relative address of the old page&gt; &lt;address of the new page&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">for example.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Redirect \/commercial\/ http:\/\/www.commercial.company.mybox.com\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">An additional separate guide on this issue can be found <a href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-alias-a-domain-to-another-www-htaccess-redirect-301-address\/\">HERE<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Block_resource_hotlinking\"><\/span>Block resource hotlinking<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The openness of the Internet also enables fraudulent activities, also in the field of creating websites. How many times has it happened that your photograph has been stolen and used without permission. In addition, the photo has not even been copied, but is downloaded from your website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To prevent such situations, you can easily block the possibility of hotlinking \u2013 because this is the name for using resources from other servers without permission. Create a .htaccess file (or use an existing one) and include the following rule in it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteEngine On #this line should appear only once, if it already exists it can be omitted \nRewriteCond %{HTTP_REFERER} !^$ \nRewriteCond %{HTTP_REFERER} !^http:\/\/(.+.)?firma.ro &#91;NC] \nRewriteRule ^pictures\/.*.(jpe?g|gif|bmp|png)$ - &#91;NC,F]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Such a rule will not allow you to display on the page other than firma.pl image files from the \/images\/ directory. You can also add specific &#8220;friend&#8221; sites that we have allowed to use our resources. You need to duplicate the 3rd line and enter the appropriate domain of the &#8220;friendly&#8221; site there. At the same time, this script allows you to display images if someone enters its address directly into the browser.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If an image is hotlinked, our web server will return a 403 \u2013 No access error and the image will not be displayed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Password_protection_of_the_directory\"><\/span>Password protection of the directory<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In this way, you can protect the directory from unauthorized access by specifying a list of users who will gain such access using the login and password.<\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[25,43],"manual_kb_tag":[718,719,1292,1320,1627,4209,4210,4211,4212],"class_list":["post-46","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-hosting","manualknowledgebasecat-website-errors","manual_kb_tag-htaccess-file","manual_kb_tag-url-rewriting","manual_kb_tag-server-configuration","manual_kb_tag-rewrite-rules","manual_kb_tag-apache-htaccess","manual_kb_tag-redirects","manual_kb_tag-custom-error-pages","manual_kb_tag-error-document","manual_kb_tag-directory-index"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/46\/revisions"}],"predecessor-version":[{"id":3336,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/46\/revisions\/3336"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manualknowledgebasecat?post=46"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb_tag?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}