Return to site

WordPress htaccess File Creation Guide

broken image

In this article, we will explain to you about the WordPress .htaccess file. Plus will tell you how it works and why WordPress .htaccess files are used. We will discuss how to modify and how to create it. .htaccess means hypertext access file that is used for internet servers to run software like apache. It manages the directory where it is situated, and some other directories under the parent directory. With the help of the .htaccess file, you can manage or add with so many functionalities.

 

Some of the basic features of the .htaccess file are

  • Rewriting URL
  • Setup a 301 redirect
  • Cache control
  • Password protect a directory

Use of WordPress .htaccess file and why it is used

The main object to use this file is to set up a new setting of the apache web server. While switching to any feature of server on or off, you will find this helpful. The main use of this file is to build redirects from www to non www URL and non www URL to www URL.

 

Another usage of this file is that it comes with some benefits for specific blocking bots, files or adding MIME types. .htaccess file is most important to keep track of security settings of your WordPress. While developing WordPress you will get this feature because you will need to set up some of these setting as per your requirements.

 

Sometimes, this file comes in handy with WordPress installation as a default. Whereas, sometimes you will not find it because it might be hidden in the root folder of the installation.

 

The WordPress htaccess file code is

# BEGIN WordPress

RewriteRule ^index\.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

# END WordPress

 

If you are a beginner and do not have any idea about .htaccess file and looking to add this code in .htaccess file or you might be looking to create a new code then you have landed on the correct page. let see how to find this file in Cpanel.

 

Actually this file is already crafted on your web host when installing WordPress. But you will not be able to find this file because it will be hidden in another folder.

 

Now you need to go to Cpanel then you will find a file management system under this you need to mouse click on file manager. A small window will appear on the screen when you click on file manager plus you will be able to see so many options.

 

The default .htaccess file location is a WordPress installation root directory. Before clicking on go do not forget to click on check box 'show hidden files'.

 

In the file list, you will be able to find .htaccess file. On this file right click and click on the edit button. A text editor will get open where you can edit the files. After modifying make sure to save changes. With the FTP server, you will be able to access the file manager. Using FTP client i.e. FileZilla you will be able to access files.

 

In Cpanel how to create WordPress htaccess file

In WordPress installation root directory if there is no .htaccess file then from Cpanel you can easily create .htaccess file. Steps to create files are to go to the file manager. Now at the left-hand side on the top, you will find the 'new file' option. While clicking on it a small window will appear as a pop-up. You can add a file name and directory here.

 

Now on the new file name filed you have to add .htaccess on it. After this mouse click on 'create a new file'. And refresh your file manager. Finally, you have created .htaccess on the list.

 

If you are looking for a plugin to edit this file and a plugin that is compatible with every professional WordPress themes then you can go with WordPress SEO by Yoast.

 

Conclusion:

.htaccess file plays an important role that should work properly with WordPress because it provides so many of features.