Recently, we advised a user to delete .htaccess file from their site to solve a common WordPress error. The user was unable to find their .htaccess file and thought that there was something wrong with his website. For beginners, things like this can be very confusing. In this article, we will show why you can’t find .htaccess file on your WordPress site, and how to create one when needed.
What is .htaccess file?
.htaccess file is a server configuration file which tells your server how to handle certain things on your website. Like how to redirect users, password protect admin area, or protect some directories, etc.
The dot before the file name indicates that it is a hidden file. When you are accessing your web server through FTP, you will not be able to see .htaccess file unless your FTP client is forced to show hidden files.
Sometimes even when you have forced your FTP client to show hidden files, it will still not show you .htaccess file.
Why You Can’t Find .htaccess File?
The most common reason for this is that your WordPress site has not generated a .htaccess file yet. WordPress generates .htaccess file for the first time when you set up pretty permalinks on Settings » Permalinks screen. All you need to do is to click on Save Changes button on the permalinks screen and WordPress will generate a .htaccess file in your site’s root directory.
On some rare occasion, WordPress may not be able to generate a .htaccess file for your website due to file permissions issue. In that case, WordPress will show you a notice at the bottom of the Settings » Permalinks screen, informing you that .htaccess file is not writable. If you have setup permalinks to use any other settings than default, then it will also show you the code you need to paste in your .htaccess file.
You will need to copy and paste this code in a text editor like Notepad. After that you need to save it as .htaccess file on your desktop. Now connect to your website using an FTP client and upload .htaccess file from your desktop.
If you get an error while uploading the file, then you need to change the file permission for your root directory. Let’s suppose all your WordPress files reside under
public_html folder your root directory. You need to go to its parent directory and right click on the
public_html folder. Select File Permissions, which will open a file permissions dialog box. You need to enter 755 into the file permission dialog box and then try to upload your .htaccess file to public_html folder.
We hope this article helped you find or generate .htaccess file on your WordPress site. If you are just starting out with WordPress don’t forget to check out Beginners Guides section, it has tutorials specifically written for new WordPress users. Let us know if you have any more questions or feedback in your comments below.