How to Find or Create WordPress .htaccess file in cPanel

A .htaccess (hypertext access) file is a configuration file for Web Servers running the Apache software. This file generally controls the directory it is placed and other directories inside the parent directory.

There are lots of functionality you can add or control using .htaccess file. Some basic features are :

  • Setup a 301 Redirect
  • Password Protect a Directory
  • Rewriting URLs
  • Cache Control

In most cases, .htaccess file comes by default with every WordPress installation. But some times it stays hidden in installation root folder. Here is the default code for WordPress .htaccess file :

# BEGIN WordPress
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Now if you want to add some codes in your WordPress .htaccess file or you want to create a new one but you have no idea how you can do that, then you are in the right place.

First I will show you how to find WordPress .htaccess file in your cPanel.

How to Locate .htaccess File in cPanel

Generally, .htaccess file is already created when you install WordPress on your webhost. But the period that starts the file name will keep the file hidden within the folder.

Login to your cPanel and Click on File Manager under File Managment Section.

cPanel File Manager

When you click on File Manger, a little Window will popup and you can find several options to choose while opening File Manager. WordPress Installation root directory is the Deafault WordPress htaccess File Location.

File Manager Directory Selection

Make sure, you check the box which says “Show Hidden Files (dotfiles)”. Then Click on Go. Now you can see .htaccess file in your file list.

.htaccess Edit

Right Click on the file and Click on Edit. A new window with a text editor will open up. You can edit your .htacces file and save the changes from the Editor.

You can also access file manager using FTP server. Read : How to access files using FTP Client (FileZilla).

How to Create .htaccess File in cPanel

If there is no .htaccess file in your WordPress installation root directory, you can easily create one from your cPanel and you SHOULD. Here’s How to Create an htaccess File

Access your File Manager following above steps. Now on the upper left of your Screen you will see an Option – “New File”

Create New File in cPanel

When you click on ‘New File’, a little window will Pop up. You can set the file name and directory here. Follow the image below.

File Creation in cPanel

Now put .htaccess on New File Name field. Remember .htaccess is not an extension. It’s the file name. And there will be nothing before the period.

It should not be something like text.htaccess. It’s only .htaccess. Now, click on “Create New File”. Reload your file manager. You’ll find the newly created .htaccess file on the list.

Using Plugins to Edit .htaccess File

If you don’t want to access your File Manager or FTP to Edit your .htaccess file, you can use plugins to edit it. For example, WordPress SEO by Yoast has a Feature to edit your Robots.txt and .htacces file from your dashboard.

Yoast htaccess Edit

You can use other plugins like : WP Htaccess Editor. But it’s always a good idea to edit From cPanel or FTP. Make sure you backup .htaccess file before making any changes.

Let us know if you have any queries regarding WordPress htaccess file. And don’t forget to share the info with others.

Source: https://roadtoblogging.com/locate-create-wordpress-htaccess-file-cpanel/



You might also like this video