Don’t miss the New Year’s Sale deals!
search
In this article

How to locate and create .htaccess file – A step-by-step guide

.htaccess (hypertext access) is a hidden file used to configure additional features for websites hosted on Apache Web Server. With it, you can rewrite URL, password-protect directories, enable hotlink protection, disallow access to specific IP addresses, change your website’s time zone or alter default index page, and much more. Here you’ll learn how to locate and create .htaccess file.

How to Locate an Open .htaccess File?

We will show how to locate and open .htaccess file in both Hostinger’s hPanel and cPanel.

hPanel

Finding and editing the file in Hostinger’s hPanel takes only a few clicks. Here’s how to do it:

  1. Once you’re logged in to your WordPress Dashboard, use the search feature to find the File Manager located under the Files category.
  2. By default, .htaccess is visible in hPanel’s public_html directory, so you can immediately access the file and its content by right-clicking and selecting Edit.The Edit option for the .htaccess file highlighted in the public_html folder on hPanel's File Manager

cPanel

If you are using cPanel, the process is more or less similar.

  1. Access File Manager public_html.
  2. If you can’t find the file, go to the  Settings on the upper right menu and tick the Show Hidden Files option to enable viewing.

Important! This only applies to cPanel-based hosting platforms.

How to Create .htaccess File?

If .htaccess file is not present, here’s how you create one. This method is applicable to both hPanel and cPanel:

  1. Click the New File button in the upper menu.
  2. Enter .htaccess as the file name, insert the code below and press Create to save your changes.
    # 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 WordPres
Hostinger web hosting banner

Conclusion

You’ve learned how to locate and create .htaccess file using the File Manager. .htaccess enables you to create website redirects, set default pages, password-protect directories and much more.

If you have any questions regarding this guide, let us know in the comments below!

Author
The author

Tomas A.

Tomas provides top-notch technical advice on a daily basis to our valued customers. He also likes to create websites and do various coding side projects.

What our customers say

Comments

Author
marshadeans

April 13 2018

I'm 71and still have no idea how to get rid of 403 forbidden

Author
Avinash

August 07 2019

I can access my website using http:// but I can't access directly "tripticianandaman.in". How to solve this problem ????

Author
Muneeb Shahid Shahid Pervez

September 25 2019

Thank you for this post. this help me a lot. Good luck

Author
Fulvio

March 11 2020

Hello Tomas, How can I get support from you on htaccess setting on Hostinger VPS for Laravel project? thanks!

Author
Barinderpreet Singh

August 31 2020

Can we use this for using a site without publishing it, I mean by using an html file on our desktop while testing it?

Author
James

October 18 2020

Hi, I created a website using Flask and hosted this using a free web hosting service. I redirected the URL to my personal domain name. The domain that I redirected from has https but the domain that I redirected to (my personal domain) has http. How can I use https on personal domain name? Will this tutorial solve my problem or do I need to do something else? Your help will be appreciated, Domantas G.

Author
Govind B singh

October 29 2020

if this is not a WordPress website then ??

Author
asep wildan

November 12 2020

hello there, If I try to access the web with non www, I always enter parked free, how can I access the web on the page that I created with non www?

Author
Loulou Tech

December 07 2020

Hostinger reset the htaccess file which contains my personal rules from time to time

Author
Connie

December 09 2020

Can i know what is the coding for add in WWW in my url in htacess ? no clue how to add in www.

Author
Vicente

May 10 2021

Hello, I have a doubt about the htaccess file: I added code to this file to forward a URL. It works normally fine but, at random moments, the file returns to its default status (removes the code I added). It has happened 2 times in 2 months, and I don't if it is an error or I am doing some action that resets this file. This is causing me troubles since every time it happens I receive a storm of angry clients that are not forwarded correctly. Please could you help me with this? Thanks in advance. Best regards

Author
Arif

September 11 2021

Hi there! What does " RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] " mean in the Wordpress block inside an htaccess file? Especially in the following context -- RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] What is "RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]" doing here and how does it affect the lines beneath it?

Author
turner

January 10 2022

if i made the site in VSC & just uploaded the files, what do i put insdead of wordpress?

Author
adnan

June 28 2022

i have created .htaccess file it working fine for react application but it also changing changing response of api and response comming my index.html page. I want to load only react application and not for node.js rest api, How can i do that?

Author
Francis Togor

April 20 2023

Ads are not showing on client side and only shows when I log in as administrator in WordPress

Author
Joao Andrade

July 13 2023

How do I do the same but with my index.php inside of the public_html/public folder ?

Author
Usman Ghani

May 20 2024

how to solve an error like this I have a website "abc.com/blog" but when i type "abc.com/blog//" the page still open cannot redirect to the original "abc.com/blog" what should I add in .htaccess file that if user type 2, 3,4 or unlimited slashes the page redirected to its own original URL

Author
inet

November 06 2024

Does your code apply to all websites? Or just default to wordpress source code.

Leave a reply

Please fill the required fields.Please accept the privacy checkbox.Please fill the required fields and accept the privacy checkbox.

Thank you! Your comment has been successfully submitted. It will be approved within the next 24 hours.