{"id":65521,"date":"2022-07-19T01:58:56","date_gmt":"2022-07-19T07:58:56","guid":{"rendered":"https:\/\/www.scalahosting.com\/blog\/?p=65521"},"modified":"2023-08-10T04:34:34","modified_gmt":"2023-08-10T10:34:34","slug":"where-is-the-htaccess-file-in-joomla","status":"publish","type":"post","link":"https:\/\/www.scalahosting.com\/blog\/where-is-the-htaccess-file-in-joomla\/","title":{"rendered":"Where Is the .htaccess File in Joomla?"},"content":{"rendered":"\n<p>You&#8217;d think that with an open-source content management system like Joomla, you&#8217;ll control your entire website from a <strong>nicely laid-out dashboard <\/strong>where everything is intuitive and easy to use.<\/p>\n\n\n\n<p>While this is largely true, other components also play a part in your <strong>site&#8217;s management<\/strong>. <strong>The web server<\/strong>, for example, is responsible for <strong>processing visitors&#8217; requests<\/strong>, and a lot of your site&#8217;s functionality depends on it. Its configuration is not accessible from the <strong>Joomla Administrator<\/strong>, and to make it behave the way you want it to, you often need to edit the <strong>.<\/strong><a href=\"https:\/\/www.scalahosting.com\/kb\/working-with-the-htaccess-and-redirects\/\"><strong>htaccess file<\/strong><\/a>.<\/p>\n\n\n\n<p><em>But what does this file do exactly? And where can you find it?<\/em><\/p>\n\n\n\n<p>Let&#8217;s find out.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"What-is\"><strong>What is .htaccess?<\/strong><\/h2>\n\n\n\n<p>You may have heard of <strong>Apache<\/strong>. It&#8217;s a <strong>web server application<\/strong>, and although it&#8217;s nearly thirty years old, it&#8217;s still considered one of the best solutions of its kind.<\/p>\n\n\n\n<p>Apache is far from the only web server capable of powering your <strong>Joomla project<\/strong>, but it is free, and some people are so used to it, they don&#8217;t even want to consider the alternatives. The truth is, an <a href=\"https:\/\/www.scalahosting.com\/blog\/apache-server-latest-versions-and-version-history\/\"><strong>Apache server<\/strong><\/a> can easily support your Joomla website. However, if you want to make the most of it, you need to set it up properly. And this means <strong>editing its configuration files<\/strong>.<\/p>\n\n\n\n<p><strong>Apache&#8217;s primary configuration file<\/strong> is called <strong><em>httpd.conf<\/em><\/strong>, located in the <strong><em>etc\/httpd\/conf <\/em><\/strong>directory (variations are possible depending on the Linux distribution and the web server&#8217;s version).<\/p>\n\n\n\n<p>You can open httpd.conf with a text editor and add <strong>directives<\/strong> to modify the <strong>web server&#8217;s behavior<\/strong>.<\/p>\n\n\n\n<p>The thing is, not everyone has <strong>access to the httpd.conf file<\/strong>. For example, on a shared hosting server, you have hundreds of projects running on the same machine. As a website owner, you get <strong>your own folder<\/strong>, and you&#8217;re not allowed to touch anything outside it.<\/p>\n\n\n\n<p>This isn&#8217;t ideal. Some critical tasks, such as forcing the entire website through <a href=\"https:\/\/www.scalahosting.com\/blog\/what-is-ssl-and-why-you-need-it\/\"><strong>HTTPS<\/strong><\/a>, are often impossible without Apache directives. In other words, you need to <strong>configure the web server <\/strong>according to your website&#8217;s needs, but you need to do it <strong>without touching httpd.conf<\/strong>.<\/p>\n\n\n\n<p><em>This is where the .htaccess file comes in.<\/em><\/p>\n\n\n\n<p>An .htaccess file is like httpd.conf for a single directory. It needs to be situated <strong>in your website&#8217;s document root folder <\/strong>(<em>if your site is hosted under your primary domain, that would be the <\/em><strong><em>public_html <\/em><\/strong><em>folder<\/em>). Once it&#8217;s in place, you can open it with a text editor and use the same Apache directives as in the primary configuration file without affecting other websites on the server.<\/p>\n\n\n\n<p>The .htaccess file can be used for various tasks, including <strong>setting up a custom 404 page, password-protecting a section of your website, and restricting access to the site from specific IPs<\/strong>. There are universal directives that can work on all websites, regardless of the platform they&#8217;re based on.<\/p>\n\n\n\n<p>However, many content management systems also use the .htaccess file for specific purposes. Joomla is no exception.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Joomla-and-htaccess\"><strong>Joomla and .htaccess<\/strong><\/h2>\n\n\n\n<p>There are <strong>two main Joomla-specific tasks<\/strong> you can accomplish with an .htaccess file:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"engine-friendly-URLs\"><strong>Allow search engine-friendly URLs<\/strong><\/h3>\n\n\n\n<p><strong>Joomla&#8217;s URL structure <\/strong>used to be pretty cumbersome. It contained category and article IDs and other information that didn&#8217;t really tell you what the page was about.<\/p>\n\n\n\n<p>This wasn&#8217;t great from an <a href=\"https:\/\/www.scalahosting.com\/blog\/the-ultimate-seo-checklist-for-joomla\/\"><strong>SEO perspective<\/strong><\/a>. Google and other search engines prefer human-readable URLs with keywords that show them what they can expect.<\/p>\n\n\n\n<p>To improve the <strong>CMS&#8217;s SEO performance<\/strong>, a <strong>Search Engine Friendly URLs option<\/strong> was introduced in Joomla 1.5, and by version 1.6, it was enabled by default. Even with it on, however, all URLs have <em>index.php<\/em> in them. To remove it, you need to have <strong>Apache&#8217;s rewrite module <\/strong>enabled and a few special directives in the .htaccess file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"sites-security\"><strong>Improve your site&#8217;s security by preventing popular exploits<\/strong><\/h3>\n\n\n\n<p>Joomla is under active development, which means that, as long as you use the latest version of the CMS, you can <strong>get patches and plug any recently discovered security holes<\/strong>. However, some exploits simply can&#8217;t be prevented with an update. For them, you need a <strong>properly configured .htaccess file<\/strong>.<\/p>\n\n\n\n<p>Using a few directives, you can stop quite a few attacks, including <strong>loading JavaScript code into SVG files<\/strong>, <strong>modifying HTTP requests<\/strong>, and encoding data within the URL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"How-Can-I-Find\"><strong>How Can I Find Joomla&#8217;s .htaccess File?<\/strong><\/h2>\n\n\n\n<p>You can create <strong>your own .htaccess file from scratch<\/strong>. All you need is a text editor and an understanding of<strong> Apache&#8217;s directives<\/strong>.<\/p>\n\n\n\n<p>However, you don&#8217;t need to do everything yourself. Every standard <a href=\"https:\/\/www.scalahosting.com\/blog\/how-to-install-joomla\/\"><strong>Joomla installation<\/strong><\/a> comes with a file called <strong>htaccess.txt<\/strong>. It&#8217;s already inside your site&#8217;s root directory, and it contains the directives that allow <strong>search engine-friendly URLs <\/strong>and stop the exploits mentioned in the previous section.<\/p>\n\n\n\n<p>All you need to do to make these directives come into effect is <strong>rename htaccess.txt to .htaccess<\/strong>.<\/p>\n\n\n\n<p>There are three methods for doing it:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"FTP-client\"><strong>With an FTP client<\/strong><\/h3>\n\n\n\n<p>All you need to do is navigate to the site&#8217;s document root folder, right-click on the htaccess.txt file, and select <strong>Rename<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><a href=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/1-1.png\"><img decoding=\"async\" width=\"751\" height=\"356\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/1-1.png\" alt=\"Where Is the .htaccess File in Joomla?, With an FTP client\" class=\"wp-image-65523\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/1-1.png 751w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/1-1-300x142.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"File-Manager\"><strong>With your hosting account&#8217;s File Manager<\/strong><\/h3>\n\n\n\n<p>The steps are pretty much identical. <strong>The interface may differ slightly<\/strong> from file manager to file manager, but with most, the <strong>Rename<\/strong> option is available in the context menu.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><a href=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/2-1.png\"><img decoding=\"async\" width=\"421\" height=\"399\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/2-1.png\" alt=\"Where Is the .htaccess File in Joomla?, With your hosting account&#8217;s File Manager\" class=\"wp-image-65524\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/2-1.png 421w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/2-1-300x284.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Via-SSH\"><strong>Via SSH<\/strong><\/h3>\n\n\n\n<p>It&#8217;s not mandatory, but most people prefer to navigate to the site&#8217;s document root directory first. If your site is hosted under your primary domain, you can use the following command:<\/p>\n\n\n\n<p><strong><em>$ cd ~\/public_html<\/em><\/strong><\/p>\n\n\n\n<p>Then, you need to use the <strong><em>mv <\/em><\/strong>command to rename htaccess.txt to .htaccess.<\/p>\n\n\n\n<p><strong><em>$ mv htaccess.txt .htaccess<\/em><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full mpg-gallery\"><a href=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/3-2.png\"><img decoding=\"async\" width=\"546\" height=\"162\" src=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/3-2.png\" alt=\"Where Is the .htaccess File in Joomla?, Via SSH\" class=\"wp-image-65525\" srcset=\"https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/3-2.png 546w, https:\/\/www.scalahosting.com\/blog\/wp-content\/uploads\/2022\/07\/3-2-300x89.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/a><\/figure>\n\n\n\n<p class=\"alert-green\"><strong>NOTE:<\/strong> <em>The dot in .htaccess is at the very beginning of the file name. In Linux, this indicates that the file is hidden. If you position it incorrectly or put a file extension at the end, your .htaccess file won&#8217;t work.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You&#8217;d think that with an open-source content management system like Joomla, you&#8217;ll control your entire website from a nicely laid-out &#8230;<\/p>\n","protected":false},"author":113,"featured_media":65527,"comment_status":"open","ping_status":"closed","sticky":false,"template":"single-cluster-joomla.php","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[119],"tags":[],"class_list":["post-65521","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-joomla-hosting"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/posts\/65521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/users\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/comments?post=65521"}],"version-history":[{"count":2,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/posts\/65521\/revisions"}],"predecessor-version":[{"id":65528,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/posts\/65521\/revisions\/65528"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/media\/65527"}],"wp:attachment":[{"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/media?parent=65521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/categories?post=65521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scalahosting.com\/blog\/wp-json\/wp\/v2\/tags?post=65521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}