{"id":4292,"date":"2021-08-09T13:28:27","date_gmt":"2021-08-09T13:28:27","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=4292"},"modified":"2026-03-10T09:36:45","modified_gmt":"2026-03-10T09:36:45","slug":"create-default-wordpress-htaccess-file","status":"publish","type":"post","link":"\/ph\/tutorials\/create-default-wordpress-htaccess-file","title":{"rendered":"How to locate and create the WordPress .htaccess file on cPanel and hPanel"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>When you install WordPress on your hosting account, the software adds a list of directories to your web server. From <strong>wp-admin<\/strong> that stores administrative files to the <strong>wp-content<\/strong> directory where themes and plugins are kept &ndash; these keep your pages up and running.<\/p><p>Aside from the core directories, WordPress also comes with the <strong>.htaccess<\/strong> file. In short, it is a configuration file that controls how your server is running. We will give you the details about this configuration file and information on how to locate it or create a new file entirely.<\/p><p>In particular, we&rsquo;ll guide you through the process of locating your WordPress site&rsquo;s .htaccess file in both Hostinger&rsquo;s hPanel and cPanel. Please note that Hostinger no longer uses Apache as its main web server. Instead, LiteSpeed has become its drop-in replacement with .htaccess file support, and it is used for all Hostinger&rsquo;s hosting services, including managed WordPress plans.<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Mega-WordPress-Cheat-EN.pdf\" target=\"_blank\" rel=\"noopener\">Download all in one WordPress cheat sheet<\/a><\/p><p>\n\n\n\n<div class=\"protip\">\n                    <h2 class=\"featured-snippet title\">What Is the .htaccess File<\/h2>\n                    <p>The <strong>.htaccess<\/strong> (hypertext access) is a critical WordPress core file used to enable or disable features of websites hosted on Apache. The <strong>.htaccess<\/strong> files are also referred to as server configuration files located in your WordPress root directory. By default, WordPress uses the <strong>.htaccess<\/strong> files to manage redirects and permalink structures.<\/p>\n                <\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/htaccess.png\"><img decoding=\"async\" width=\"783\" height=\"326\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/htaccess.png\" alt=\"The .htaccess file after opening it.\" class=\"wp-image-34393\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/htaccess.png 783w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/htaccess-300x125.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/htaccess-150x62.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/htaccess-768x320.png 768w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/a><\/figure>\n\n\n\n<\/p><p>Many WordPress plugins also use <strong>.htaccess<\/strong> files to operate, including most security plugins and caching plugins. These plugins modify and rewrite the <strong>.htaccess<\/strong> files to perform their functions.<\/p><p>The <strong>.htaccess<\/strong> file allows you to perform configuration changes per-directory basis, from altering your <a href=\"\/ph\/tutorials\/change-index-page-in-htaccess-with-directoryindex\">default index<\/a> page to <a href=\"\/ph\/tutorials\/php-set-timezone\">changing your website&rsquo;s timezone<\/a>. More advanced server configuration changes include the ability to:<\/p><ul class=\"wp-block-list\">\n<li><strong>Set up redirects<\/strong> &ndash; you can set a 302 redirect to your temporary domain or a <a href=\"\/ph\/tutorials\/ssl\/force-https-using-htaccess\">301 redirect<\/a> to move all HTTP traffic to your HTTPS site.<\/li>\n\n\n\n<li><strong>Rewrite URL<\/strong> &ndash; create SEO-friendly URLs to improve search engine <a href=\"https:\/\/www.semrush.com\/blog\/what-are-crawlability-and-indexability-of-a-website\/\" target=\"_blank\" rel=\"noopener\">indexability and crawlability<\/a>.<\/li>\n\n\n\n<li><strong>Enable <a href=\"\/ph\/tutorials\/hotlinking\">hotlink protection<\/a><\/strong> &ndash; the <strong>.htaccess<\/strong> file allows you to prevent hotlinking from your site and protect your bandwidth usage.<\/li>\n\n\n\n<li><strong>Modify access restriction<\/strong> &ndash; deny specific IP addresses from your site, make a certain type of files inaccessible, or completely <a href=\"\/ph\/tutorials\/htaccess\/how-to-restrict-access-to-your-website-for-everyone-except-you\">restrict access<\/a> to your site.<\/li>\n\n\n\n<li><strong>Serve custom error pages<\/strong> &ndash; customize the message that appears on your<strong> 404 error not found or <\/strong><a href=\"\/ph\/tutorials\/what-is-403-forbidden-error-and-how-to-fix-it\">403 Forbidden<\/a> pages.<\/li>\n\n\n\n<li><strong>Password-protect directories<\/strong> &ndash; command every directory to require a valid user by setting up a password and creating a <strong>.htpasswd<\/strong> file.<\/li>\n<\/ul><p>Access this free <a href=\"https:\/\/www.htaccessredirect.net\/\" target=\"_blank\" rel=\"noopener\"><strong>.htaccess<\/strong> generator page<\/a> to generate code snippets and set up more advanced rules on your site.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-locate-the-htaccess-file\">How to Locate the .htaccess File<\/h2><p>When you <a href=\"\/ph\/tutorials\/how-to-install-wordpress\">install WordPress<\/a> on Apache Web Server, the <strong>.htaccess<\/strong> file is automatically added to your root directory, generally labelled as <strong>public_html<\/strong> or <strong>www<\/strong>. However, since the file is usually hidden, you will need to use the <strong>Show Hidden Files<\/strong> option to find it.<\/p><p>The following sections will walk you through the steps of locating your WordPress site&rsquo;s <strong>.htaccess<\/strong> file in both Hostinger&rsquo;s hPanel and cPanel.<\/p><h3 class=\"wp-block-heading\" id=\"h-hpanel\">hPanel<\/h3><p>Here&rsquo;s how to find and edit your <strong>.htaccess<\/strong> file via Hostinger File Manager:<\/p><ol class=\"wp-block-list\">\n<li>Access your hPanel dashboard. Click on <strong>File Manager<\/strong> on your hPanel dashboard.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/05\/The-File-Manager-button-in-hPanel-website-management-menu.png\"><img decoding=\"async\" width=\"1024\" height=\"372\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/05\/The-File-Manager-button-in-hPanel-website-management-menu-1024x372.png\" alt=\"The File Manager button in the hPanel website management menu\" class=\"wp-image-85104\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/05\/The-File-Manager-button-in-hPanel-website-management-menu-1024x372.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/05\/The-File-Manager-button-in-hPanel-website-management-menu-300x109.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/05\/The-File-Manager-button-in-hPanel-website-management-menu-150x55.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/05\/The-File-Manager-button-in-hPanel-website-management-menu-768x279.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/05\/The-File-Manager-button-in-hPanel-website-management-menu.png 1460w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"2\" class=\"wp-block-list\">\n<li>By default, the <strong>.htaccess<\/strong> file is not hidden in hPanel. Thus, simply click on your <strong>public_html<\/strong> directory and look for a file labeled as <strong>.htaccess<\/strong>.<img decoding=\"async\" width=\"1024\" height=\"482\" class=\"wp-image-82388\" style=\"width: 1000px\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/filemanager-publichtml-htaccess.png\" alt=\".htaccess file highlighted in the public_html folder on hPanel's File Manager\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-publichtml-htaccess.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-publichtml-htaccess-300x141.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-publichtml-htaccess-150x71.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-publichtml-htaccess-768x362.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n<\/ol><ol start=\"3\" class=\"wp-block-list\">\n<li>Access the file and its content by right-clicking and selecting <strong>Edit<\/strong>.<img decoding=\"async\" width=\"1024\" height=\"484\" class=\"wp-image-82390\" style=\"width: 1000px\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/filemanager-publichtml-htaccess-edit.png\" alt=\"The Edit option for the .htaccess file highlighted in the public_html folder on hPanel's File Manager\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-publichtml-htaccess-edit.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-publichtml-htaccess-edit-300x142.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-publichtml-htaccess-edit-150x71.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-publichtml-htaccess-edit-768x363.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li>\n<\/ol><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/ph\/wordpress-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner-1024x300.png\" alt=\"\" class=\"wp-image-111781\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/06\/New-WP_in-text-banner-1024x300.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/06\/New-WP_in-text-banner-300x88.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/06\/New-WP_in-text-banner-150x44.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/06\/New-WP_in-text-banner-768x225.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/06\/New-WP_in-text-banner-1536x450.png 1536w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2024\/06\/New-WP_in-text-banner.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-cpanel\">cPanel<\/h3><p>If you use cPanel, the process is more or less similar:<\/p><ol class=\"wp-block-list\">\n<li>Log into your cPanel account. Locate the <strong>Files<\/strong> section and click <strong>File Manager<\/strong>.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cpanel-file-manager-2.png\"><img decoding=\"async\" width=\"1024\" height=\"219\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cpanel-file-manager-2-1024x219.png\" alt=\"Accessing the File Manager on cPanel.\" class=\"wp-image-39061\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-file-manager-2.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-file-manager-2-300x64.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-file-manager-2-150x32.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-file-manager-2-768x164.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-file-manager-2-1536x328.png 1536w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-file-manager-2-2048x438.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"2\" class=\"wp-block-list\">\n<li>Access the <strong>public_html<\/strong> directory. Click on your WordPress folder. In this case, it&rsquo;s labeled as <strong>wp<\/strong>. Then, look for the <strong>.htaccess<\/strong> file.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/wp-publichtml.png\"><img decoding=\"async\" width=\"1024\" height=\"471\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/wp-publichtml-1024x471.png\" alt=\"WP folder on cPanel's File Manager.\" class=\"wp-image-34395\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/wp-publichtml.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/wp-publichtml-300x138.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/wp-publichtml-150x69.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/wp-publichtml-768x353.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/wp-publichtml-1536x707.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"3\" class=\"wp-block-list\">\n<li>If you can&rsquo;t find the <strong>.htaccess<\/strong> file, go to <strong>Settings<\/strong> on the upper right menu and tick the <strong>Show Hidden Files<\/strong> option to enable viewing.<\/li>\n<\/ol><figure class=\"wp-block-image size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cPanel-show-hidden-files.png\"><img decoding=\"async\" width=\"761\" height=\"484\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cPanel-show-hidden-files.png\" alt=\"Enabling the showing of hidden files on cPanel.\" class=\"wp-image-34389\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cPanel-show-hidden-files.png 761w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cPanel-show-hidden-files-300x191.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cPanel-show-hidden-files-150x95.png 150w\" sizes=\"(max-width: 761px) 100vw, 761px\" \/><\/a><\/figure><ol start=\"4\" class=\"wp-block-list\">\n<li>The system will begin to fetch your directories&rsquo; content, and you will soon see the <strong>.htaccess<\/strong> file on the list.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cpanel-htaccess-2.png\"><img decoding=\"async\" width=\"1024\" height=\"342\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cpanel-htaccess-2-1024x342.png\" alt=\".htaccess on cPanel's File Manager.\" class=\"wp-image-39072\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-htaccess-2.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-htaccess-2-300x100.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-htaccess-2-150x50.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-htaccess-2-768x256.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-htaccess-2-1536x512.png 1536w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-htaccess-2-2048x683.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><ol start=\"5\" class=\"wp-block-list\">\n<li>Simply click on the file and check the <strong>Edit<\/strong> button to open it.<\/li>\n<\/ol><figure class=\"wp-block-image size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cpanel-edit-htaccess-1.png\"><img decoding=\"async\" width=\"1024\" height=\"362\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cpanel-edit-htaccess-1-1024x362.png\" alt=\"Clicking Edit on .htaccess on the cPanel.\" class=\"wp-image-39077\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-edit-htaccess-1.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-edit-htaccess-1-300x106.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-edit-htaccess-1-150x53.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-edit-htaccess-1-768x272.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-edit-htaccess-1-1536x543.png 1536w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cpanel-edit-htaccess-1-2048x724.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>Now that you have located your <strong>.htaccess<\/strong> file, you can start editing the file. Start adding code snippets above or below the existing code to enhance the functionality of your WordPress site. However, before you make any configurations, there are several factors worth paying attention to:<\/p><ul class=\"wp-block-list\">\n<li>If you have more than one domain in your hosting plan, each domain will have its own <strong>.htaccess<\/strong> file in its <strong>public_html<\/strong> directory.<\/li>\n\n\n\n<li>Since <strong>.htaccess<\/strong> is a server configuration file, messing up the code can cause server errors.<\/li>\n\n\n\n<li>It is highly recommended to <a href=\"\/ph\/tutorials\/backup-wordpress\">create a backup<\/a>. This way, you can restore your WordPress site to its stable state whenever an error happens.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-how-to-create-a-htaccess-file\">How to Create a .htaccess File<\/h2><p>There are a few instances where your WordPress installation will not include the<strong> .htaccess <\/strong>file by default. Alternatively, a broken plugin might corrupt this server configuration file and disrupt your site. In these cases, you will need to create a new file from your hosting control panel manually.<\/p><p>hPanel users will locate the <strong>New file<\/strong> button on the left sidebar menu on your <strong>File Manager<\/strong> page.<\/p><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/filemanager-newfile.png\"><img decoding=\"async\" width=\"1024\" height=\"466\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/filemanager-newfile-1024x466.png\" alt=\"New File button on hPanel's File Manager highlighted\" class=\"wp-image-82391\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-newfile.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-newfile-300x136.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-newfile-150x68.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/filemanager-newfile-768x349.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>If you use cPanel, choose the <strong>New File<\/strong> button on the upper-left corner of your screen.<\/p><figure class=\"wp-block-image size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cPanel-file-manager-new.png\"><img decoding=\"async\" width=\"1024\" height=\"59\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/cPanel-file-manager-new-1024x59.png\" alt=\"New File option on cPanel.\" class=\"wp-image-34386\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cPanel-file-manager-new.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cPanel-file-manager-new-300x17.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cPanel-file-manager-new-150x9.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cPanel-file-manager-new-768x44.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/08\/cPanel-file-manager-new-1536x89.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>Enter <strong>.htaccess<\/strong> as the file name, then insert the code below:<\/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\n&lt;IfModule mod_rewrite.c&gt;\nRewriteEngine On\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>Once you&rsquo;ve added the code, press <strong>Create<\/strong> to save your changes. Keep in mind that the code is universal for all WordPress sites. However, <a href=\"\/ph\/tutorials\/what-is-a-cms\/\">other content management systems<\/a> (CMSs) will have different code for their <strong>.htaccess <\/strong>files.<\/p><p>Aside from the method above, you can also use a text editor such as <strong>Notepad<\/strong> to create a <strong>.htaccess <\/strong>file, then upload it to your web server using an <a href=\"\/ph\/tutorials\/ftp\/filezilla-ftp-configuration\">FTP client<\/a>.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>The <strong>.htaccess<\/strong> file is a configuration document for use in WordPress websites. This file plays an important role in keeping your site accessible, as it determines how the server runs and functions.<\/p><p>Every WordPress installation will include a <strong>.htaccess<\/strong> file that you can access through your hosting control panel or FTP client. When you host multiple sites, your web server will also have multiple<strong> .htaccess<\/strong> files.<\/p><p>By making full use of your <strong>.htaccess<\/strong> files, you can perform various configuration changes on a per-directory basis. This includes blacklisting or whitelisting specific IP addresses, redirecting traffic from HTTP to HTTPS, and setting up a password on every directory.<\/p><p>In this guide, you have learned how to locate the <strong>.htaccess<\/strong> files on your server. If the .htaccess files are not present for some reason, you need to manually create one and upload it to your server. Simply create a new file in the public_html directory, label it as <strong>.htaccess<\/strong>, and fill out the default code.<\/p><p>Give it a try, and should you have any further questions, please leave them in the comments below.<\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Learn Other Expert WordPress Techniques<\/h4>\n                    <p><a href=\"\/ph\/tutorials\/activate-wordpress-multisite\">WordPress Multisite<\/a><br>\n<a href=\"\/ph\/tutorials\/headless-wordpress\">Headless WordPress<\/a><br>\n<a href=\"\/ph\/tutorials\/wordpress-rest-api\">WordPress REST API Tutorial<\/a><br>\n<a href=\"\/ph\/tutorials\/how-to-use-xampp-wordpress\/\">How to Use Xampp<\/a><br>\n<a href=\"\/ph\/tutorials\/wordpress-heartbeat\">What Is WordPress Heartbeat<\/a><br>\n<a href=\"\/ph\/tutorials\/how-to-become-wordpress-developer\">How to Become a WordPress Developer<\/a><br>\n<a href=\"\/ph\/tutorials\/best-wordpress-frameworks\">Best WordPress Frameworks<\/a><br>\n<a href=\"\/ph\/tutorials\/how-to-perform-search-and-replace-in-wordpress-database\/\">How to Perform a WordPress Search and Replace in the Database<\/a><\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-wordpress-htaccess-faq\">WordPress .htaccess FAQ<\/h2><p>Learn more about WordPress .htaccess from these frequently asked questions.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1677590848221\"><h3 class=\"schema-faq-question\">How Do I edit .htaccess in WordPress?<\/h3> <p class=\"schema-faq-answer\">To edit .htaccess in WordPress, access the file via an FTP client or File Manager, then make changes using a text editor. It&rsquo;s important to back up the file before editing and to use proper syntax to avoid errors.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1677590880057\"><h3 class=\"schema-faq-question\">What Is the Default WordPress .htaccess File?<\/h3> <p class=\"schema-faq-answer\">The default WordPress .htaccess file is a configuration file used by Apache web servers to control website access and URL structure. It includes rules for WordPress permalinks and security settings to help prevent unauthorized access and protect against malicious attacks.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>When you install WordPress on your hosting account, the software adds a list of directories to your web server. From wp-admin that stores administrative files to the wp-content directory where themes and plugins are kept &ndash; these keep your pages up and running. Aside from the core directories, WordPress also comes with the .htaccess file. [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ph\/tutorials\/create-default-wordpress-htaccess-file\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":126493,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Locate and Create the WordPress .htaccess File","rank_math_description":"Check out our comprehensive guide on how to locate and create the default WordPress .htaccess file on your hosting control panel.","rank_math_focus_keyword":"wordpress htaccess","footnotes":""},"categories":[22632],"tags":[],"class_list":["post-4292","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/create-default-wordpress-htaccess-file","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/criar-arquivo-htaccess-wordpress","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/htaccess-wordpress","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/crear-archivo-htaccess","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cara-membuat-file-htaccess-wordpress","default":0},{"locale":"it-IT","link":"https:\/\/www.hostinger.com\/it\/tutorial\/file-htaccess","default":0},{"locale":"nl-NL","link":"https:\/\/www.hostinger.com\/nl\/tutorials\/wordpress-htaccess","default":0},{"locale":"ja-JP","link":"https:\/\/www.hostinger.com\/jp\/tutorials\/create-default-wordpress-htaccess-file\/","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/create-default-wordpress-htaccess-file","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/create-default-wordpress-htaccess-file","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/create-default-wordpress-htaccess-file","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/crear-archivo-htaccess","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/crear-archivo-htaccess","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/crear-archivo-htaccess","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/criar-arquivo-htaccess-wordpress","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/create-default-wordpress-htaccess-file","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/create-default-wordpress-htaccess-file","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/create-default-wordpress-htaccess-file","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/create-default-wordpress-htaccess-file","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/4292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/comments?post=4292"}],"version-history":[{"count":54,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/4292\/revisions"}],"predecessor-version":[{"id":126489,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/4292\/revisions\/126489"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media\/126493"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media?parent=4292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/categories?post=4292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/tags?post=4292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}