Sun

How to find and create the .htaccess file in the shared or reseller hosting package?

  1. Home
  2. Knowledge Base
  3. Hosting
  4. How to find and create the .htaccess file in the shared or reseller hosting package?

How to find and create the .htaccess file in the shared or reseller hosting package?

Every website comes with files that are required to keep the site up and running. So that website could run on Apache web server (or some other web server that supports .htaccess file), it should have .htaccess file. This file plays a vital role in keeping websites accessible. 

So when WordPress is installed, or you upload WordPress website to the hosting package, it should include .htaccess file. This file is the essential file that controls how the web server is running.

This file is supported just in some web server, including Apache, and you can find it on your cPanel through File Manager.

Thus, if your websites are hosted on the server and the server’s web server is Apache, you can use this guide too. It explains where you should find this file in your shared or reseller hosting package. However, if you will not be able to find that file, you will find here the solution how to create that file for your website.

What’s the .htaccess file? 

.htaccess file is a hidden text file to configure commands for websites hosted on the servers that support Apache or other web servers. Meaning this web server configuration file controls how a web server responds to various incoming requests.

You can redirect website visitors in this file, lock some directories, block IPs, set a password for the files, etc. So these commands should be written correctly that the server could read them and do. 

A free tool helps generate .htaccess code snippets and set up various commands on your website. 

How to find the .htaccess file in cPanel? 

You need to connect to your cPanel and navigate to File Manager. There you should find your website folder. Usually, it is the public_html folder. So click on that folder and search the .htaccess file.

Note. The file that begins with a dot (.file_name) is a hidden file on most file systems. So this file is not shown by default. However, you can make it via File Manager to show that hidden file.

If you cannot find that file, for example, .htaccess, you should open your File Manager and click on the website folder, then you need to go to the Settings.

On the upper right menu and tick the Show Hidden Files option to enable viewing of these hidden files.

After that, you should see all your website files as well as hidden files. Then you should see the .htaccess file. 

If you want to open that file and edit it, you should right-click and select Edit or View.

Note. It would help if you were careful when you edited this file. Since it is a server configuration file, messing up the code might cause server errors. 

Note. Before changing something inside your website files, we highly recommend making a backup of your website. Thus you will be able to restore that backup if any errors will occur after changes. 

How to create the .htaccess file?

However, if you cannot find your h.taccess file, you are even enabled to show all hidden files, it might be a few reasons for that. For example, a broken plugin might corrupt this file and disrupt your site. So, in this case, you will need to create a .htaccess file by yourself, and here you will see how to do that. 

Firstly, you will need to open File Manager and navigate to your website folder. Then you will see the New File button on the upper-left corner of your screen.

After that, you will see an option to create a new file, so enter .htaccess as the file name and click on Create New File to save the new file.

Once the file is created, click on the .htaccess file and click on Edit. Then you need to insert this code:

# 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

Note. This code is universal for WordPress websites. So keep in mind that other websites created on different CMSs will use different codes for .htaccess files.

Once the code is inserted, click to save changes on Save Changes. 

Note. If you host more than one website on your hosting package, every website needs to have a separate .htaccess file located inside the website folder.

Was this article helpful?

Related Articles