{"id":553,"date":"2019-10-31T13:13:21","date_gmt":"2019-10-31T13:13:21","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/htaccesshow-to-locate-htaccess-file-on-cpanel-file-manager\/"},"modified":"2026-11-03T19:33:11","modified_gmt":"2026-11-03T19:33:11","slug":"locate-and-create-htaccess","status":"publish","type":"post","link":"\/ng\/tutorials\/locate-and-create-htaccess\/","title":{"rendered":"How to find and create the .htaccess file"},"content":{"rendered":"<p class=\"wp-block-paragraph\">The <code>.htaccess<\/code> file is a hidden server configuration file typically found in your website&#8217;s root directory, such as <code>public_html<\/code>. It&#8217;s used by Apache and compatible web servers to manage redirects, URL rewriting, and access restrictions.<\/p><p class=\"wp-block-paragraph\">You can locate it through your hosting control panel, FTP\/SFTP, or SSH. If the file is missing, you can create one manually, provided your website requires it. Below, we&#8217;ll cover the common file locations, access methods, and safe configuration steps.<\/p>\n\n\n\n<\/p><h2 id=\"h-where-is-the-htaccess-file-located\" class=\"wp-block-heading h-t-title-2\">Where is the .htaccess file located?<\/h2><p class=\"wp-block-paragraph\">The <code>.htaccess<\/code> file is usually located in your website&#8217;s root directory, alongside files such as <code>index.php<\/code>. On many hosting accounts, this directory is named <code>public_html<\/code>. However, the exact location depends on your hosting environment and website configuration.<\/p><p class=\"wp-block-paragraph\">Here are the most common locations:<\/p><figure tabindex=\"0\" class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Hosting environment<\/th><th>Typical .htaccess location<\/th><\/tr><tr><td>Hostinger web hosting<\/td><td><code>public_html\/.htaccess<\/code><\/td><\/tr><tr><td>cPanel hosting<\/td><td><code>public_html\/.htaccess<\/code> or the domain&#8217;s document root<\/td><\/tr><tr><td>WordPress<\/td><td>Website root directory, usually alongside <code>index.php<\/code><\/td><\/tr><tr><td>FTP\/SFTP<\/td><td>Website&#8217;s document root on the server<\/td><\/tr><tr><td>VPS with Apache<\/td><td>Configured document root, such as <code>\/var\/www\/html\/.htaccess<\/code><\/td><\/tr><tr><td>Local XAMPP installation<\/td><td>Inside the website folder under <code>htdocs<\/code><\/td><\/tr><\/tbody><\/table><\/figure><p class=\"wp-block-paragraph\">On WordPress websites, the file often contains <a data-click-id=\"hgr-post-content-link-permalink-and-url-rewrite-configuration\" href=\"\/ng\/tutorials\/create-default-wordpress-htaccess-file\/\">permalink and URL rewrite configuration<\/a>, which controls how the web server processes requests for individual pages and posts.<\/p><p class=\"wp-block-paragraph\"><strong>Important:<\/strong> Files beginning with a dot are commonly hidden, so you may need to enable hidden-file visibility in your file manager or FTP client. If the file still doesn&#8217;t appear, it may not exist yet.<\/p><p class=\"wp-block-paragraph\">The <code>.htaccess<\/code> file is supported by Apache and compatible web servers such as LiteSpeed. Servers running Nginx don&#8217;t process <code>.htaccess<\/code> files, so their configuration rules must be managed differently.<\/p><h2 id=\"h-how-to-find-and-open-the-htaccess-file\" class=\"wp-block-heading h-t-title-2\">How to find and open the .htaccess file<\/h2><p class=\"wp-block-paragraph\">You can locate and open the <code>.htaccess<\/code> file using your hosting control panel, an FTP\/SFTP client, or SSH. The best method depends on how you access your website files.<\/p><p class=\"wp-block-paragraph\">Before editing the file, <strong>download a backup of the original version<\/strong>. Incorrect configuration rules can cause redirects to fail or make your website inaccessible.<\/p><h3 class=\"wp-block-heading h-t-title-3\">Using Hostinger File Manager<\/h3><p class=\"wp-block-paragraph\">Hostinger File Manager displays hidden files by default, so you can find <code>.htaccess<\/code> directly in your website&#8217;s root directory.<\/p><ol start=\"1\" class=\"wp-block-list\">\n<li>Log in to your Hostinger dashboard, navigate to Websites, hover over your website, and click <strong>Manage site<\/strong>.<\/li>\n\n\n\n<li>Open <strong>File Manager<\/strong>, navigate to <code>public_html<\/code>, and locate <code>.htaccess<\/code>.<\/li>\n\n\n\n<li>Right-click the file and select <strong>Edit<\/strong> to view its contents.<strong><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"484\" class=\"wp-image-81453\" style=\"width: 1000px\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/10\/filemanager-publichtml-htaccess-edit.png\" alt=\"The Edit option for the .htaccess file highlighted in the public_html folder on hPanel&apos;s File Manager\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/10\/filemanager-publichtml-htaccess-edit.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/10\/filemanager-publichtml-htaccess-edit.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/10\/filemanager-publichtml-htaccess-edit.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/10\/filemanager-publichtml-htaccess-edit.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/strong><\/li>\n<\/ol><p class=\"wp-block-paragraph\">If the file isn&#8217;t listed, it may not exist yet. You can create one using the instructions in the next section.<\/p><h3 class=\"wp-block-heading h-t-title-3\">Using cPanel File Manager<\/h3><p class=\"wp-block-paragraph\">If your hosting provider uses cPanel, you can access <code>.htaccess<\/code> through its built-in File Manager.<\/p><ol start=\"1\" class=\"wp-block-list\">\n<li>Log in to cPanel and open <strong>File Manager<\/strong> under <strong>Files<\/strong>.<\/li>\n\n\n\n<li>Navigate to <code>public_html<\/code> or the document root configured for your domain.<\/li>\n\n\n\n<li>If <code>.htaccess<\/code> isn&#8217;t visible, click <strong>Settings<\/strong> in the upper-right corner, enable <strong>Show Hidden Files (dotfiles)<\/strong>, and save your preferences.<\/li>\n\n\n\n<li>Locate <code>.htaccess<\/code>, right-click it, and select <strong>Edit<\/strong> to open the file.<\/li>\n<\/ol><h3 class=\"wp-block-heading h-t-title-3\">Using FTP or SFTP<\/h3><p class=\"wp-block-paragraph\">An FTP client such as FileZilla lets you access website files without opening your hosting control panel.<\/p><ol start=\"1\" class=\"wp-block-list\">\n<li>Connect to your hosting server using the connection details provided by your hosting provider. Use SFTP when it&#8217;s supported.<\/li>\n\n\n\n<li>Navigate to your website&#8217;s document root, typically <code>public_html<\/code>.<\/li>\n\n\n\n<li>If you&#8217;re using FileZilla and can&#8217;t see <code>.htaccess<\/code>, select <strong>Server &rarr; Force showing hidden files<\/strong>.<\/li>\n\n\n\n<li>Locate the file and use your client&#8217;s <strong>View\/Edit<\/strong> option to open it in a text editor.<\/li>\n<\/ol><p class=\"wp-block-paragraph\">Make sure to upload any saved changes if your FTP client asks you to synchronize the edited file with the server.<\/p><h3 class=\"wp-block-heading h-t-title-3\">Using SSH<\/h3><p class=\"wp-block-paragraph\">If you have SSH access to your hosting server, you can locate <code>.htaccess<\/code> directly from the terminal.<\/p><ol start=\"1\" class=\"wp-block-list\">\n<li>Connect to your server using SSH.<\/li>\n\n\n\n<li>Navigate to your website&#8217;s document root. For example, run <code>cd \/var\/www\/html<\/code> if that&#8217;s the configured location.<\/li>\n\n\n\n<li>Run <code>ls -la<\/code> to display all files, including hidden files.<\/li>\n\n\n\n<li>Open <code>.htaccess<\/code> using a text editor such as Nano by running <code>nano .htaccess<\/code>.<\/li>\n<\/ol><p class=\"wp-block-paragraph\">If the file doesn&#8217;t exist, Nano may open an empty buffer instead. Exit without saving if you only want to check whether the file is present.<\/p><h3 class=\"wp-block-heading h-t-title-3\">On a local development environment<\/h3><p class=\"wp-block-paragraph\">If you&#8217;re developing a website locally with XAMPP, the <code>.htaccess<\/code> file is usually located inside the website folder under <code>htdocs<\/code>.<\/p><p class=\"wp-block-paragraph\">For example, common locations include:<\/p><ul class=\"wp-block-list\">\n<li><strong>Windows:<\/strong> <code>C:xampphtdocsmywebsite.htaccess<\/code><\/li>\n\n\n\n<li><strong>Linux:<\/strong> <code>\/opt\/lampp\/htdocs\/mywebsite\/.htaccess<\/code><\/li>\n<\/ul><p class=\"wp-block-paragraph\">Replace <code>mywebsite<\/code> with your actual project folder name. The location may differ if you&#8217;ve changed the local server&#8217;s document root.<\/p><p class=\"wp-block-paragraph\">You can open the file using a text editor such as VS Code or Notepad++. Make sure hidden files are visible in your file browser.<\/p><h2 id=\"h-how-to-create-a-htaccess-file-if-its-missing\" class=\"wp-block-heading h-t-title-2\">How to create a .htaccess file if it&#8217;s missing<\/h2><p class=\"wp-block-paragraph\">If your website doesn&#8217;t have an <code>.htaccess<\/code> file, you can create one manually in the website&#8217;s document root. However, <strong>not every website needs this file<\/strong>. Create it only when your application or a specific server configuration requires it.<\/p><p class=\"wp-block-paragraph\">The following method works with Hostinger File Manager and cPanel.<\/p><ol start=\"1\" class=\"wp-block-list\">\n<li>Open your hosting account&#8217;s <strong>File Manager<\/strong> and navigate to your website&#8217;s root directory, typically <code>public_html<\/code>.<\/li>\n\n\n\n<li>Click <strong>New File<\/strong> or <strong>+ File<\/strong>, depending on your control panel.<\/li>\n\n\n\n<li>Enter <code>.htaccess<\/code> as the filename, including the period at the beginning.<\/li>\n\n\n\n<li>Create the file, then open it with the built-in text editor.<\/li>\n\n\n\n<li>Add the configuration rules required by your application and save your changes.<\/li>\n<\/ol><p class=\"wp-block-paragraph\">You can also create the file with an FTP\/SFTP client by uploading a plain-text file named <code>.htaccess<\/code> to your website&#8217;s document root. If you&#8217;re using SSH, navigate to the correct directory and run <code>touch .htaccess<\/code> to create an empty file.<\/p><p class=\"wp-block-paragraph\"><strong>Important:<\/strong> Back up any existing configuration before making changes. An empty <code>.htaccess<\/code> file doesn&#8217;t change your website&#8217;s behavior until you add supported directives.<\/p><h3 class=\"wp-block-heading h-t-title-3\">Creating a default .htaccess file for WordPress<\/h3><p class=\"wp-block-paragraph\">WordPress uses <code>.htaccess<\/code> rules to manage permalinks on compatible web servers. If your WordPress <code>.htaccess<\/code> file is missing, first open <strong>Settings &rarr; Permalinks<\/strong> in your WordPress dashboard and click <strong>Save Changes<\/strong>. WordPress may regenerate the file automatically if the server configuration allows it to write to the file.<\/p><p class=\"wp-block-paragraph\">If you need to restore the default configuration manually, the following example applies to a standard single-site WordPress installation in the domain&#8217;s root directory:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># BEGIN WordPress\n&lt;IfModule mod_rewrite.c&gt;\nRewriteEngine On\nRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]\nRewriteBase \/\nRewriteRule ^index.php$ - [L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . \/index.php [L]\n&lt;\/IfModule&gt;\n# END WordPress<\/pre><p class=\"wp-block-paragraph\">These rules direct requests for URLs that don&#8217;t correspond to existing files or directories to WordPress.<\/p><p class=\"wp-block-paragraph\"><strong>Don&#8217;t use this configuration for non-WordPress websites.<\/strong> WordPress Multisite installations, subdirectory installations, and websites with custom rewrite rules may require different configurations. Avoid overwriting rules added by plugins or your hosting provider.<\/p><h2 id=\"h-how-to-safely-edit-htaccess-rules\" class=\"wp-block-heading h-t-title-2\">How to safely edit .htaccess rules<\/h2><p class=\"wp-block-paragraph\">Once you&#8217;ve located or created your <code>.htaccess<\/code> file, you can use it to configure website redirects, access restrictions, and other supported server settings.<\/p><p class=\"wp-block-paragraph\">Before making changes, follow these precautions:<\/p><ul class=\"wp-block-list\">\n<li><strong>Back up the original file.<\/strong> Keep a copy so you can restore the previous configuration if something goes wrong.<\/li>\n\n\n\n<li><strong>Check server compatibility.<\/strong> Apache and compatible servers such as LiteSpeed support <code>.htaccess<\/code>, but Nginx doesn&#8217;t process these files.<\/li>\n\n\n\n<li><strong>Test your changes.<\/strong> After saving the file, check important pages and URLs for unexpected redirects or server errors.<\/li>\n<\/ul><p class=\"wp-block-paragraph\">One common use is <a data-click-id=\"hgr-post-content-link-redirecting-visitors-to-a-different-domain\" href=\"\/ng\/tutorials\/how-to-redirect-a-domain\/\">redirecting visitors to a different domain<\/a> when moving a website. You can configure these redirects through supported <code>.htaccess<\/code> rules without modifying every page individually.<\/p><p class=\"wp-block-paragraph\">If your website returns a 500 Internal Server Error after editing <code>.htaccess<\/code>, restore your backup and review the new directives for syntax errors or unsupported settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The .htaccess file is a hidden server configuration file typically found in your website&#8217;s root directory, such as public_html. It&#8217;s used by Apache and compatible web servers to manage redirects, URL rewriting, and access restrictions. You can locate it through your hosting control panel, FTP\/SFTP, or SSH. If the file is missing, you can create [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/locate-and-create-htaccess\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":37,"featured_media":152241,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Find and Create the .htaccess File","rank_math_description":"Learn where to find the .htaccess file and how to create it if missing. Follow steps for hPanel, cPanel, FTP, SSH, WordPress, and local environments.","rank_math_focus_keyword":"create htaccess file","_content_updated_date":"","footnotes":""},"categories":[22715],"tags":[],"class_list":["post-553","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical-aspects"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/locate-and-create-htaccess","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-localizar-ou-criar-um-arquivo-htaccess\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/trouver-creer-htaccess\/","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/que-es-el-archivo-htaccess\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cara-membuat-htaccess-file\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/locate-and-create-htaccess","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/locate-and-create-htaccess","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/locate-and-create-htaccess","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/locate-and-create-htaccess","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/locate-and-create-htaccess","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/locate-and-create-htaccess","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/locate-and-create-htaccess","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/que-es-el-archivo-htaccess\/","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/que-es-el-archivo-htaccess\/","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/que-es-el-archivo-htaccess\/","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-localizar-ou-criar-um-arquivo-htaccess\/","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=553"}],"version-history":[{"count":28,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/553\/revisions"}],"predecessor-version":[{"id":155045,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/553\/revisions\/155045"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media\/152241"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}