{"id":20583,"date":"2020-01-30T15:31:17","date_gmt":"2020-01-30T15:31:17","guid":{"rendered":"https:\/\/www.arimetrics.com\/glosario-digital\/htaccess"},"modified":"2026-09-29T11:43:33","modified_gmt":"2026-09-29T11:43:33","slug":"htaccess","status":"publish","type":"encyclopedia","link":"https:\/\/www.arimetrics.com\/en\/digital-glossary\/htaccess","title":{"rendered":"Htaccess"},"content":{"rendered":"<p><img decoding=\"async\" class=\"boxpad alignright wp-image-14445 size-full\" src=\"https:\/\/www.arimetrics.com\/wp-content\/uploads\/2020\/01\/htaccess-1.png\" alt=\".htaccess file\" width=\"300\" height=\"300\" srcset=\"https:\/\/www.arimetrics.com\/wp-content\/uploads\/2020\/01\/htaccess-1.png 300w, https:\/\/www.arimetrics.com\/wp-content\/uploads\/2020\/01\/htaccess-1-150x150.png 150w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>An <strong>.htaccess file<\/strong> is a distributed configuration file that applies <a href=\"https:\/\/www.arimetrics.com\/en\/digital-glossary\/apache\">Apache HTTP Server<\/a> directives to a specific directory. Its rules may also affect subdirectories, depending on the site&#8217;s hierarchy and the main server configuration.<\/p>\n<p>The initial dot makes it a <strong>hidden file<\/strong> on Unix-like systems. It is not a universal web server technology or a method for shortening a <a href=\"https:\/\/www.arimetrics.com\/en\/digital-glossary\/url\">URL<\/a>. Its behavior depends on Apache, the installed modules, and the directives permitted by the server administrator.<\/p>\n\n<h2>How .htaccess Works<\/h2>\n<p>When Apache receives a request, it may look for `.htaccess` files from higher-level directories down to the directory containing the requested resource. The <strong>applicable rules<\/strong> are combined along that path, so a file in one folder can affect that folder and the directories below it.<\/p>\n<p>The <strong>AllowOverride<\/strong> directive in the main configuration determines whether Apache reads these files and which categories of instructions it accepts. `AllowOverrideList` can restrict permission to named directives. If the server uses `AllowOverride None`, the file is ignored even when it exists.<\/p>\n<p>The instructions use the same <strong>general syntax<\/strong> as the main configuration, but not every directive is allowed in directory context. The result also depends on modules such as `mod_rewrite`, `mod_headers`, `mod_expires`, and `mod_authz_core`.<\/p>\n<h2>Common Directives<\/h2>\n<p>The file can address local requirements without changing the global configuration. Its <strong>common uses<\/strong> depend on the available permissions and modules:<\/p>\n<ul>\n<li><strong>Redirects:<\/strong> Send a request to another address with the appropriate response code.<\/li>\n<li><strong>Rewrites:<\/strong> Transform visible paths into internal paths processed by an application.<\/li>\n<li><strong>Errors:<\/strong> Assign custom documents to responses such as a <a href=\"https:\/\/www.arimetrics.com\/en\/digital-glossary\/404-error\">404 Error<\/a>.<\/li>\n<li><strong>Caching:<\/strong> Define expiration headers for selected resource types.<\/li>\n<li><strong>Compression:<\/strong> Enable response compression when the corresponding module is available.<\/li>\n<\/ul>\n<p>It may also set MIME types, directory indexes, authentication, or headers. An `.htaccess` file does not activate these capabilities on its own: each <strong>valid directive<\/strong> requires the correct context, module, and permission.<\/p>\n<h2>URL Rewriting<\/h2>\n<p>The `mod_rewrite` module evaluates conditions and rules to change how a path is processed. An <strong>internal rewrite<\/strong> serves content from another location without changing the address shown by the browser. A redirect instead returns a response that sends the client to another URL.<\/p>\n<p>This <strong>technical distinction<\/strong> matters when migrating pages, normalizing domains, or enforcing HTTPS. A <a href=\"https:\/\/www.arimetrics.com\/en\/digital-glossary\/301-redirect\">301 redirect<\/a> communicates a permanent move, while other codes express different situations. The code should match the meaning of the change, not merely produce the expected destination.<\/p>\n<p>Poorly ordered rules can create <strong>loops<\/strong>, chains, duplicate paths, or unexpected parameters. These effects hinder crawling, dilute signals, and increase response time. `.htaccess` can implement SEO decisions, but it does not replace planning for architecture or destination URLs.<\/p>\n<h2>Access Control<\/h2>\n<p>Apache can restrict resources by authentication, identity, host, or IP address. In Apache 2.4, the authorization system normally uses `Require` directives. The <strong>actual scope<\/strong> depends on the directory containing the file and any exceptions defined at lower levels.<\/p>\n<p>Several <strong>different functions<\/strong> that are often confused should be separated when interpreting access rules:<\/p>\n<ul>\n<li><strong>Authentication:<\/strong> Verifies identity through a configured provider.<\/li>\n<li><strong>Authorization:<\/strong> Decides whether that identity may access the resource.<\/li>\n<li><strong>IP filtering:<\/strong> Allows or denies requests based on the observed address.<\/li>\n<li><strong>File protection:<\/strong> Prevents sensitive resources from being served from the public tree.<\/li>\n<li><strong>Error pages:<\/strong> Presents a controlled response without correcting the cause of the failure.<\/li>\n<\/ul>\n<p>Invalid syntax or a forbidden directive can produce a <a href=\"https:\/\/www.arimetrics.com\/en\/digital-glossary\/error-500\">500 Error<\/a>. Hiding a file or blocking a path also does not repair application vulnerabilities. `.htaccess` is a <strong>configuration layer<\/strong>, not a complete security system.<\/p>\n<h2>Server Performance<\/h2>\n<p>When distributed files are enabled, Apache must check for their presence and read the applicable rules during requests. This <strong>repeated work<\/strong> adds overhead even when some directories contain no file. The impact can grow with the number of directory levels and rules evaluated.<\/p>\n<p>When <strong>administrative access<\/strong> is available, Apache recommends placing directives in the main configuration, which is loaded when the server starts or reloads. `.htaccess` is most useful in managed hosting and environments where the content owner cannot edit that configuration.<\/p>\n<p>Compression, caching, and efficient rules can support <a href=\"https:\/\/www.arimetrics.com\/en\/digital-glossary\/wpo\">WPO<\/a>, but the file does not guarantee a fast website. Servers such as Nginx and Microsoft IIS use other mechanisms, and some content management systems regenerate their rules. Any change must be assessed within the <strong>specific platform<\/strong> serving the requests.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The .htaccess file applies per-directory directives in Apache. Learn how it handles redirects, access, errors, caching, and performance.<\/p>\n","protected":false},"author":6,"featured_media":81081,"template":"","encyclopedia-tag":[1262],"class_list":["post-20583","encyclopedia","type-encyclopedia","status-publish","has-post-thumbnail","hentry","encyclopedia-tag-http-status"],"_links":{"self":[{"href":"https:\/\/www.arimetrics.com\/en\/wp-json\/wp\/v2\/encyclopedia\/20583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.arimetrics.com\/en\/wp-json\/wp\/v2\/encyclopedia"}],"about":[{"href":"https:\/\/www.arimetrics.com\/en\/wp-json\/wp\/v2\/types\/encyclopedia"}],"author":[{"embeddable":true,"href":"https:\/\/www.arimetrics.com\/en\/wp-json\/wp\/v2\/users\/6"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.arimetrics.com\/en\/wp-json\/wp\/v2\/media\/81081"}],"wp:attachment":[{"href":"https:\/\/www.arimetrics.com\/en\/wp-json\/wp\/v2\/media?parent=20583"}],"wp:term":[{"taxonomy":"encyclopedia-tag","embeddable":true,"href":"https:\/\/www.arimetrics.com\/en\/wp-json\/wp\/v2\/encyclopedia-tag?post=20583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}