How to Locate and Create the WordPress .htaccess File on cPanel and hPanel

1. Locate the WordPress .htaccess File on cPanel

The .htaccess file is located in the root directory of your WordPress installation. To access it, log into your cPanel account and navigate to the File Manager.

Once you’re in the File Manager, navigate to the root directory of your WordPress installation. You should see the .htaccess file in the list of files.

2. Create the WordPress .htaccess File on cPanel

If you don’t see the .htaccess file in the list of files, you can create it. To do this, click on the “+ File” button at the top of the File Manager.

In the “New File Name” field, enter “.htaccess” (without the quotes). Then click the “Create New File” button.

3. Locate the WordPress .htaccess File on hPanel

The .htaccess file is located in the root directory of your WordPress installation. To access it, log into your hPanel account and navigate to the File Manager.

Once you’re in the File Manager, navigate to the root directory of your WordPress installation. You should see the .htaccess file in the list of files.

4. Create the WordPress .htaccess File on hPanel

If you don’t see the .htaccess file in the list of files, you can create it. To do this, click on the “+ File” button at the top of the File Manager.

In the “New File Name” field, enter “.htaccess” (without the quotes). Then click the “Create New File” button.

Once the file is created, you can add the necessary code to it. You can find the code in the WordPress Codex or in the documentation of the plugin or theme you’re using.

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 – these keep your pages up and running.

Aside from the core directories, WordPress also comes with the .htaccess file. In short, it is a configuration file that controls how your server is running. The file is only supported in a few web servers, including Apache.

If your website is hosted on an Apache web server and you want to use the .htaccess file, this article is for you. We will give you the details about this configuration file and information on how to locate it and create a new file entirely.

What Is the .htaccess File

The .htaccess file after opening it.

The .htaccess (hypertext access) is a critical WordPress core file used to enable or disable features of websites hosted on Apache. The .htaccess files are also referred to as server configuration files located in your WordPress root directory. By default, WordPress uses the .htaccess files to manage redirects and permalink structures.

Many WordPress plugins also use .htaccess files to operate, including most security plugins and caching plugins. These plugins modify and rewrite the .htaccess files to perform their functions.

The .htaccess file allows you to perform configuration changes per-directory basis, from altering your default index page to changing your website’s time zone. More advanced server configuration changes include the ability to:

  • Set up redirects – you can set a 302 redirect to your temporary domain or a 301 redirect to move all HTTP traffic to your HTTPS site.
  • Rewrite URL – create SEO-friendly URLs to improve search engine indexability and crawlability.
  • Enable hotlink protection – the .htaccess file allows you to prevent hotlinking from your site and protect your bandwidth usage.
  • Modify access restriction – deny specific IP addresses from your site, make a certain type of files inaccessible, or completely restrict access to your site.
  • Serve custom error pages – customize the message that appears on your 404 error not found pages.
  • Password-protect directories – command every directory to require a valid user by setting up a password and creating a .htpasswd file.

Access this free .htaccess generator page to generate code snippets and set up more advanced rules on your site.

How to Locate the .htaccess File

When you install WordPress on Apache Web Server, the .htaccess file is automatically added to your root directory, generally labeled as public_html or www. However, since the file is usually hidden, you will need to use the Show Hidden Files option to find it.

The following sections will walk you through the steps of locating your WordPress site’s .htaccess file in both Hostinger’s hPanel and cPanel.

hPanel

Here’s how to find and edit your .htaccess file via Hostinger File Manager:

  1. Access your hPanel dashboard. Go to the Files menu and click on File Manager.
The File Manager on Hostinger's hPanel.
  1. By default, the .htaccess file is not hidden in hPanel. Thus, simply click on your public_html directory and look for a file labeled as .htaccess.
.htaccess on the public_html directory.
  1. Access the file and its content by right-clicking and either selecting Open or Edit.
Clicking edit on the .htaccess file on hPanel.

cPanel

If you use cPanel, the process is more or less similar:

  1. Log into your cPanel account. Locate the Files section and click File Manager.
Accessing the File Manager on cPanel.
  1. Access the public_html directory. Click on your WordPress folder. In this case, it’s labeled as wp. Then, look for the .htaccess file.
WP folder on cPanel's File Manager.
  1. If you can’t find the .htaccess file, go to the Settings on the upper right menu and tick the Show Hidden Files option to enable viewing.
Enabling the showing of hidden files on cPanel.
  1. The system will begin to fetch your directories’ content, and you will soon see the .htaccess file on the list.
.htaccess on cPanel's File Manager.
  1. Simply click on the file and check the Edit button to open it.
Clicking Edit on .htaccess on the cPanel.

Now that you have located your .htaccess 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:

  • If you have more than one domain in your hosting plan, each domain will have its own .htaccess file in its public_html directory.
  • Since .htaccess is a server configuration file, messing up the code can cause server errors.
  • It is highly recommended to create a backup. This way, you can restore your WordPress site to its stable state whenever an error happens.

How to Create a .htaccess File

There are a few instances where your WordPress installation will not include the .htaccess 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.

hPanel users will locate the New File button on the upper-right corner of your File Manager page.

New File button on hPanel's File Manager.

If you use cPanel, choose the New File button on the upper-left corner of your screen.

New File option on cPanel.

Enter .htaccess as the file name, then insert the code below:

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Once you’ve added the code, press Create to save your changes. Keep in mind that the code is universal for all WordPress sites. However, other content management systems (CMSs) will have different code for their .htaccess files.

Aside from the method above, you can also use a text editor such as Notepad to create a .htaccess file, then upload it to your web server using an FTP client.

Conclusion

The .htaccess file is a configuration document for use in websites running on Apache web server. This file plays an important role in keeping your site accessible. It determines how the server runs and functions.

Every WordPress installation will include a .htaccess 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 .htaccess files.

By making full use of your .htaccess 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.

In this guide, you have learned how to locate the .htaccess 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 .htaccess, and fill out the default code.

Give it a try, and should you have any further questions, please leave them in the comments below.

WordPress .htaccess FAQ

Learn more about WordPress .htaccess from these frequently asked questions.

How Do I edit .htaccess in WordPress?

To edit .htaccess in WordPress, access the file via an FTP client or File Manager, then make changes using a text editor. It’s important to back up the file before editing and to use proper syntax to avoid errors.

What Is the Default WordPress .htaccess File?

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.

How to Locate and Create the WordPress .htaccess File on cPanel and hPanel

The WordPress .htaccess file is an important part of your WordPress website. It is a configuration file that controls the directory it is placed in, as well as all subdirectories. It can be used to control access to your website, redirect visitors, and even improve your website’s performance.

If you are using cPanel or hPanel to manage your WordPress website, you may need to locate and create the WordPress .htaccess file. This article will explain how to do this.

Locating the WordPress .htaccess File

The WordPress .htaccess file is usually located in the root directory of your website. This is the same directory that contains the wp-admin and wp-content folders. To locate the .htaccess file, you will need to use an FTP client or the File Manager in cPanel or hPanel.

Once you have connected to your website via FTP or the File Manager, you will need to navigate to the root directory. If you see a file named “.htaccess”, then you have located the WordPress .htaccess file.

Creating the WordPress .htaccess File

If you do not see a .htaccess file in the root directory, then you will need to create one. To do this, you will need to use an FTP client or the File Manager in cPanel or hPanel.

Once you have connected to your website via FTP or the File Manager, you will need to navigate to the root directory. Then, you will need to create a new file and name it “.htaccess”. Make sure that the file is saved as a plain text file.

Once the file has been created, you will need to add the following code to the file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Once you have added the code to the file, you will need to save it. You should now have a functioning WordPress .htaccess file.

Conclusion

The WordPress .htaccess file is an important part of your WordPress website. It can be used to control access to your website, redirect visitors, and even improve your website’s performance. If you are using cPanel or hPanel to manage your WordPress website, you may need to locate and create the WordPress .htaccess file. This article has explained how to do this.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?