{"id":2589,"date":"2020-10-01T13:49:07","date_gmt":"2020-10-01T13:49:07","guid":{"rendered":"https:\/\/www.copahost.com\/blog\/?p=2589"},"modified":"2024-10-31T14:45:02","modified_gmt":"2024-10-31T14:45:02","slug":"htaccess","status":"publish","type":"post","link":"https:\/\/www.copahost.com\/blog\/htaccess\/","title":{"rendered":"Htaccess: Learn everything about this file"},"content":{"rendered":"<p>Have you ever hosted a website or researched how this service works? If so, you&#8217;ve probably seen or heard about <strong>htaccess<\/strong> files. These files behave differently from the .<a href=\"https:\/\/www.copahost.com\/blog\/what-is-html\/\">html<\/a> or .txt extensions, which are widely used in these services. The &#8220;.htaccess&#8221; is a text string in code where you can be giving orders directly to your <a href=\"https:\/\/www.copahost.com\/blog\/what-is-web-server\/\">server<\/a>. Therefore, it is through it that you can perform several optimizations of your website.<\/p>\n<p>So, in this article we will understand the following topics:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.copahost.com\/blog\/htaccess\/#title_01\">What does the .htaccess file do?<\/a><\/li>\n<li><a href=\"https:\/\/www.copahost.com\/blog\/htaccess\/#title_02\">What can you do with the .htaccess file?<\/a><\/li>\n<li><a href=\"https:\/\/www.copahost.com\/blog\/htaccess\/#title_03\">When to use the .htaccess file?<\/a><\/li>\n<li><a href=\"https:\/\/www.copahost.com\/blog\/htaccess\/#title_04\">How should I use this file?<\/a><\/li>\n<li><a href=\"https:\/\/www.copahost.com\/blog\/htaccess\/#title_05\">Its importance for SEO<\/a><\/li>\n<\/ul>\n<p><a name=\"title_01\"><\/a><\/p>\n<h2>What does the .htaccess file do?<\/h2>\n<p>Its name comes from &#8220;HyperText access&#8221;. It works at the directory level, so you can allow one or more administrators to execute orders. With these orders, you can configure a website, through the Apache server system. For example:<\/p>\n<pre class=\"lang:apache decode:true\">Options +FollowSymlinks\nRewriteEngine on\nrewritecond %{http_host} exemple.com [nc]\nrewriterule ^(.*)$ http:\/\/www.exemple.com\/$1 [r=301,nc]<\/pre>\n<p>Using the example above, you can configure access to your website without using \u201cwww.\u201d. This is useful because it facilitates the work of the user and the searcher, improving <a href=\"https:\/\/www.copahost.com\/blog\/what-is-seo-and-how-it-works\/\">SEO<\/a>, just because they find your address with the <a href=\"https:\/\/www.copahost.com\/blog\/url\/\">URL<\/a> \u201cexample.com\u201d.<\/p>\n<p>You can use .htaccess within the root directory, that is, throughout your site. This means that you can include a general function in \u201cwww.example.com\u201d. However, you can also include a function only in a directory or content, that is, a tab, such as \u201cwww.exemple.com\/tab1\u201d.<br \/>\n<a name=\"title_02\"><\/a><\/p>\n<h2>What can you do with the .htaccess file?<\/h2>\n<p>The .htaccess file is made of plain text, however, with it, you can execute several orders and solve thousands of problems within your website. With the right commands you can:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.copahost.com\/blog\/create-custom-404-error-page-htaccess\/\">Customize error pages<\/a> on your website;<\/li>\n<li><a href=\"https:\/\/www.copahost.com\/blog\/password-protect-folder-site-htaccess\/\"> Password protect your website<\/a>;<\/li>\n<li>Deny access to the site by IP;<\/li>\n<li>Change the default directory page;<\/li>\n<li>Include website page under maintenance;<\/li>\n<li><a href=\"https:\/\/www.copahost.com\/blog\/how-to-redirect-a-url-to-another-url\/\">Redirect<\/a> users to other pages;<\/li>\n<li>Redirect visits to a secure <a href=\"https:\/\/www.copahost.com\/blog\/http-vs-https\/\">HTTPS<\/a> server;<\/li>\n<li>Shorten URLs;<\/li>\n<li>Create friendly URLs;<\/li>\n<li>Improve SEO, among many other functions.<\/li>\n<\/ul>\n<p><a name=\"title_03\"><\/a><\/p>\n<h2>When to use the .htaccess file?<\/h2>\n<p>You must use this file to optimize your website. However, only when the server gives you access to this feature.<\/p>\n<p>In some cases, you may have access to the server&#8217;s configuration file through a system or platform, and you can give commands to your website there.<br \/>\n<a name=\"title_04\"><\/a><\/p>\n<h2>How should I use this file?<\/h2>\n<p>You should always place the .htaccess file in the root folder of the <a href=\"https:\/\/www.copahost.com\/blog\/best-domain-and-hosting-provider\/\">hosting server.<\/a> You can usually identify this folder as public_html on the hosting server.<\/p>\n<p>Also, the name of this file must always have the dot at the beginning, for it to take effect, that is, it must be named as &#8220;<strong>.htaccess&#8221;<\/strong>. This extension can be opened in any text editor, so if you are a developer, you can use your preferred editor to edit it.<\/p>\n<p>Therefore, you can create this file using the file manager of your control panel, or you can upload it via <a href=\"https:\/\/www.copahost.com\/blog\/ftp-file-transfer\/\">FTP<\/a>. The &#8220;.htaccess&#8221; works on any web server, such as <a href=\"https:\/\/www.apache.org\/\">Apache<\/a>, <a href=\"https:\/\/www.copahost.com\/blog\/nginx-500-internal-server-error\/\">NGINX<\/a>, <a href=\"https:\/\/www.iis.net\/\">IIS<\/a>, etc.<br \/>\n<a name=\"title_05\"><\/a><\/p>\n<h2>Its importance for SEO<\/h2>\n<p>If you still don&#8217;t know what <strong>SEO<\/strong> is, we recommend <a href=\"https:\/\/www.copahost.com\/blog\/what-is-seo-and-how-it-works\/\">reading on<\/a>.<\/p>\n<p>But in a nutshell, SEO is the optimization of your website to improve search engine results. That is, it is used for you to improve accesses through organic results in search engines.<\/p>\n<p>Nowadays, if your website is not optimized, it is not easily found, and you lose a lot of traffic.<\/p>\n<p>There are several ways to improve a website&#8217;s SEO. Among them, Htaccess can help a lot.<\/p>\n<p>With .htaccess you improve SEO, as it allows you to give orders to the site and improve its performance on the internet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever hosted a website or researched how this service works? If so, you&#8217;ve probably seen or heard about htaccess files. These files behave differently from the .html or .txt extensions, which are widely used in these services. The &#8220;.htaccess&#8221; is a text string in code where you can be giving orders directly to [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":2592,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114,63,74],"tags":[],"class_list":["post-2589","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-other-tutorials","category-security","category-seo"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Htaccess: Learn everything about this file - Copahost<\/title>\n<meta name=\"description\" content=\"In this article you will understand what it is and how to use the HTACCESS file on your server, How it works and how to use it to increase SEO.\" \/>\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.copahost.com\/blog\/htaccess\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Htaccess: Learn everything about this file - Copahost\" \/>\n<meta property=\"og:description\" content=\"In this article you will understand what it is and how to use the HTACCESS file on your server, How it works and how to use it to increase SEO.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.copahost.com\/blog\/htaccess\/\" \/>\n<meta property=\"og:site_name\" content=\"Copahost\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-01T13:49:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-31T14:45:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1120\" \/>\n\t<meta property=\"og:image:height\" content=\"440\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rafael Marques\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rafael Marques\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/\"},\"author\":{\"name\":\"Rafael Marques\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/1d2394d0fe0aa6712bab970668feb112\"},\"headline\":\"Htaccess: Learn everything about this file\",\"datePublished\":\"2020-10-01T13:49:07+00:00\",\"dateModified\":\"2024-10-31T14:45:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/\"},\"wordCount\":619,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png\",\"articleSection\":[\"Other tutorials\",\"Security\",\"SEO\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.copahost.com\/blog\/htaccess\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/\",\"url\":\"https:\/\/www.copahost.com\/blog\/htaccess\/\",\"name\":\"Htaccess: Learn everything about this file - Copahost\",\"isPartOf\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png\",\"datePublished\":\"2020-10-01T13:49:07+00:00\",\"dateModified\":\"2024-10-31T14:45:02+00:00\",\"description\":\"In this article you will understand what it is and how to use the HTACCESS file on your server, How it works and how to use it to increase SEO.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.copahost.com\/blog\/htaccess\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/#primaryimage\",\"url\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png\",\"contentUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png\",\"width\":1120,\"height\":440,\"caption\":\"Htaccess Learn everything about this file\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.copahost.com\/blog\/htaccess\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.copahost.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Htaccess: Learn everything about this file\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#website\",\"url\":\"https:\/\/www.copahost.com\/blog\/\",\"name\":\"Copahost\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.copahost.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\",\"name\":\"Copahost\",\"url\":\"https:\/\/www.copahost.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png\",\"contentUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png\",\"width\":223,\"height\":40,\"caption\":\"Copahost\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/1d2394d0fe0aa6712bab970668feb112\",\"name\":\"Rafael Marques\",\"description\":\"Brazilian Web Developer and Writer!\",\"sameAs\":[\"https:\/\/ialife.com.br\/\",\"https:\/\/www.instagram.com\/rafamarquesrmb\/\",\"https:\/\/www.linkedin.com\/in\/rafamarquesrmb\/\"],\"url\":\"https:\/\/www.copahost.com\/blog\/author\/rafael\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Htaccess: Learn everything about this file - Copahost","description":"In this article you will understand what it is and how to use the HTACCESS file on your server, How it works and how to use it to increase SEO.","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.copahost.com\/blog\/htaccess\/","og_locale":"en_US","og_type":"article","og_title":"Htaccess: Learn everything about this file - Copahost","og_description":"In this article you will understand what it is and how to use the HTACCESS file on your server, How it works and how to use it to increase SEO.","og_url":"https:\/\/www.copahost.com\/blog\/htaccess\/","og_site_name":"Copahost","article_published_time":"2020-10-01T13:49:07+00:00","article_modified_time":"2024-10-31T14:45:02+00:00","og_image":[{"width":1120,"height":440,"url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png","type":"image\/png"}],"author":"Rafael Marques","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rafael Marques","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.copahost.com\/blog\/htaccess\/#article","isPartOf":{"@id":"https:\/\/www.copahost.com\/blog\/htaccess\/"},"author":{"name":"Rafael Marques","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/1d2394d0fe0aa6712bab970668feb112"},"headline":"Htaccess: Learn everything about this file","datePublished":"2020-10-01T13:49:07+00:00","dateModified":"2024-10-31T14:45:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.copahost.com\/blog\/htaccess\/"},"wordCount":619,"commentCount":0,"publisher":{"@id":"https:\/\/www.copahost.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png","articleSection":["Other tutorials","Security","SEO"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.copahost.com\/blog\/htaccess\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.copahost.com\/blog\/htaccess\/","url":"https:\/\/www.copahost.com\/blog\/htaccess\/","name":"Htaccess: Learn everything about this file - Copahost","isPartOf":{"@id":"https:\/\/www.copahost.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.copahost.com\/blog\/htaccess\/#primaryimage"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png","datePublished":"2020-10-01T13:49:07+00:00","dateModified":"2024-10-31T14:45:02+00:00","description":"In this article you will understand what it is and how to use the HTACCESS file on your server, How it works and how to use it to increase SEO.","breadcrumb":{"@id":"https:\/\/www.copahost.com\/blog\/htaccess\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.copahost.com\/blog\/htaccess\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.copahost.com\/blog\/htaccess\/#primaryimage","url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png","contentUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2020\/07\/Htaccess-Learn-everything-about-this-file.png","width":1120,"height":440,"caption":"Htaccess Learn everything about this file"},{"@type":"BreadcrumbList","@id":"https:\/\/www.copahost.com\/blog\/htaccess\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.copahost.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Htaccess: Learn everything about this file"}]},{"@type":"WebSite","@id":"https:\/\/www.copahost.com\/blog\/#website","url":"https:\/\/www.copahost.com\/blog\/","name":"Copahost","description":"","publisher":{"@id":"https:\/\/www.copahost.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.copahost.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.copahost.com\/blog\/#organization","name":"Copahost","url":"https:\/\/www.copahost.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png","contentUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png","width":223,"height":40,"caption":"Copahost"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/1d2394d0fe0aa6712bab970668feb112","name":"Rafael Marques","description":"Brazilian Web Developer and Writer!","sameAs":["https:\/\/ialife.com.br\/","https:\/\/www.instagram.com\/rafamarquesrmb\/","https:\/\/www.linkedin.com\/in\/rafamarquesrmb\/"],"url":"https:\/\/www.copahost.com\/blog\/author\/rafael\/"}]}},"_links":{"self":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/2589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/comments?post=2589"}],"version-history":[{"count":4,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/2589\/revisions"}],"predecessor-version":[{"id":4127,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/2589\/revisions\/4127"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/media\/2592"}],"wp:attachment":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/media?parent=2589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/categories?post=2589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/tags?post=2589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}