How to Create the Default WordPress .htaccess File

How to Create the Default WordPress .htaccess File

Running into an obstacle when updating the .htaccess file? Or perhaps you accidentally deleted that important file? Well, don’t push the panic button just yet. Keep scrolling and learn how to create the default WordPress .htaccess file so you can configure some additional settings for your site.

Upgrade your site with Hostinger’s WordPress Hosting!

Get Started Here

What Is the .htaccess File?

The .htaccess file is an essential WordPress’ core file to reconfigure specific settings of the Apache Web Server. This file helps you enable or disable certain features of your server, like creating a redirection from non-www to www URLs or resetting permalinks structure.

Additionally, the .htaccess file can handle your WordPress security settings. You can use it to set up privileges for particular files, configure password protection, and block spambots.

Once you’ve installed WordPress on the Apache webserver, you can find the .htaccess file in your root directory. However, this file is usually hidden, so you need to enable the Show Hidden Files option to access it.

But in some rare instances, your WordPress installation may not contain the .htaccess file. Thankfully, you can manually create the default .htaccess file using your hosting control panel.

How to Create the Default WordPress .htaccess File?

Here’s how you can create the .htaccess file from Hostinger’s hPanel:

  1. Navigate to Files -> File Manager.
  2. Select your site’s domain and hit ​Go to File Manager.
  3. Go to the public_html folder and click the New File icon at the top of the page. Then, name the file “.htaccess”.This image shows you how to create default .htaccess file in Hostinger's hPanel
  4. Open the new WordPress .htaccess file and paste the following 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]
    # END WordPress
  5. Hit Save & Close.

Alternatively, you can create the default .htaccess file using any text editor on your computer (e.g., Notepad), then upload it to your web server via an FTP client.

Congratulations! You’ve successfully created your default WordPress .htaccess file. Next, visit your WordPress website to ensure that the file works properly. Often, incorrect .htaccess configuration triggers 500 internal errors.


The .htaccess file makes your website work properly. It tells the server how to run your website, or determines what content to load. Equally important, you can use this file to set up WordPress security settings, such as preventing or blocking spambots.

In this tutorial, you’ve learned how to create the default WordPress .htaccess file. Simply create a new file in the public_html folder, name it .htaccess, and insert the default .htaccess code.

Have it a try, and good luck. If you have any further questions, hit us in the comments section below.

The Author


Domantas G. / @domantas

Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.

Related tutorials


itroz Reply

January 23 2018

Thanks for the awesome article


    Gediminas B.

    Replied on February 15 2018

    No problem! It's great to hear that you found it useful! :)


Kaien Reply

February 21 2019

Thanks, you gave easy and right method 👍


MIchael Reply

July 31 2019

Great resource :)


Raejsh Reply

November 29 2019

Great Job!!!!!!!!!!!


Aylin Reply

June 20 2020

Hello. I can!t reach my website through https://................./wp-login.php adress. I have uploaded htaccess file, wp-config.php file separately but they are not making a difference. Please help me, I am not a code writer:( Thanks a lot


    Tomislav T.

    Replied on July 14 2020

    Hey Aylin! To open your website through wp-admin you will need to have an active SSL certificate on your domain name. :) Please make sure you have SSL installed, and then you can try accessing the page via HTTPS again!


Brad Reply

June 27 2020

Thanks. Very helpful


John Reply

December 20 2020

Hey!! I accidently deleted my .htaccess file and now my categories section is blank. Even though al categories are there in categories link. but not showing in post editor Could you please help me solving this? Screenshot for ref -



    Replied on February 09 2021

    Hi, John! If this happened after removing the .htaccess file, first thing I'd suggest would be looking into it's restoration options. A lot of hosts will have the option to restore one file only. For Hostinger plans, you'll find it from hPanel -> Backups :)

Leave a reply




This site uses Akismet to reduce spam. Learn how your comment data is processed.

Become a part of Hostinger now!

More in WordPress
How to Install WordPress on Docker (Windows, MacOS and Linux)
How to Install WordPress on Docker (Windows, macOS and Linux)