In this tutorial, we will explain how you can fix the .htaccess file missing problem in WordPress. This is a very common problem that most of the WordPress beginners face.
Recently, we advised a user to add some lines in the .htaccess file to solve a WordPress error. But the user reported that he is unable to find the .htaccess file, though the file was present there. With this incident, we realize that it is very common for beginner users to face such issues. Hence, we thought to write this article to show why you can’t find .htaccess file and how to fix the .htaccess missing issue in WordPress. Also, if needed, how you can create the file in your hosting account.
What is a .htaccess file?
The .htaccess file is a server configuration file which stores instructions for your server describing how to handle certain things on your website. For example, how to redirect users, defining non-indexable pages, password protect directories or admin area etc.
For more details, you can check our guide on how to adjust WordPress PHP settings using the .htaccess file.
The "." (dot) before the file name indicates that it is a hidden file. Thus, none of the FTP clients or file managers shows this file by default.
How to Fix the .htaccess File Missing Issue?
As the .htaccess is a hidden file, it is not viewable normally by accessing the web server account using an FTP program or file managers. If you access your hosting account using FTP or the cpanel file manager, you will not be able to see .htaccess file unless your FTP client or file manager is forced to show hidden files.
To view the file, you have to find and enable the "show hidden files" option in your FTP or file manager program. An example using the FileZilla FTP program shown below:
What’s If You Still Can’t find .htaccess File?
If you still can’t find the .htaccess file in the server space, then probably the file is not created.
One of the most common reasons for this is that your WordPress site has not created a .htaccess file yet. Normally, WordPress creates .htaccess file for the first time when you set up pretty permalinks on Settings » Permalinks screen.
In that case, all you need to do is to select a pretty permalink structure and click on Save Changes button on the permalinks screen. This way, the WordPress will generate a .htaccess file in your site’s root directory (public_html or htdocs).
But rarely, WordPress may not be able to create a .htaccess file for your website due to file permissions issue.
In that case, WordPress will display you a message at the bottom of the permalinks settings screen, informing you that .htaccess file is not writable. If you have selected permalinks to use any other settings than the default, then it will also show you some lines of codes you need to paste in your .htaccess file.
All you will need to do is copy and paste this code into a text editor and save it as the .htaccess file on your PC. Now connect to your web hosting account using an FTP client and upload the .htaccess file from your local PC to the root folder (public_htms or htdocs).
If there is a permission issue in the root directory then you will an error while uploading the file to the server. To solve this issue, you need to go to its parent directory and right click on the public_html or htdocs folder. Then Select the File Permissions option to open the file permissions dialog box.
Here, you need to enter 755 into the Numeric value field and then try to upload your .htaccess file to public_html or htdocs folder again.
If the issue still not resolved, then contact your web hosting provider to change the permission for you or to provide help in creating a .htaccess file for you.
This is the time when a responsive web hosting provider with knowledgeable technical staffs is required. And this is the reason why we recommend BlueHost or SiteGround or Hostinger to host your website because they have great customer service.
We hope that you have enjoyed the above article describing how to fix the .htaccess file missing issue. Be with us to explore free training on Leading Technologies and Certifications.
Leave us some comments if you have any questions or need further help on the above topic, we will be happy to help you.