In WordPress the default .htaccess file is a set of codes that handle the permalink structure of your site. If you don’t have a .htaccess file on your host, simply create a file named 1.htaccess with notepad. Paste the code below into the file and upload it to your root. Rename the file to ‘.htaccess’.
WordPress websites require a few essential files to function properly. .htaccess is one of those files. WordPress default .htaccess code has a few responsibilities. If you are unfamiliar with this file, in this article, we tend to explain what it is and why you need it.
What Is .htaccess File?
The .htaccess file is a configuration file for the Apache web server. In other words, this file contains rules that your server must follow. This file is usually located in your root directory and often is hidden. There is a dot (.htaccess) before the name, which means the file is hidden.
WordPress default .htaccess code has a primary task. This code determines how permalinks should be displayed. This file has several functions. For example, it tells your permalinks to help your SEO. In addition, it helps with your security and it is needed for SSL certificate. It also manages 301 redirects and plugins.
When you change your permalinks, htaccess gets created automatically. But if this does not happen you will have to create it manually. After creating this file, every time you make changes to your permalinks this file too gets changed.
What is the WordPress Default .htaccess Code?
Default htaccess code is a piece of code in the htaccess file which rewrites permalinks. This code whether you create manually or automatically must be in the htaccess file.
As we mentioned, you can create this file automatically and manually.
How to Automatically Create .htaccess File?
To do so head over to your dashboard > settings > permalinks and then click on save. htaccess will be created automatically on your root directory.
How to Manually Create .htaccess File?
To do so you need to use an FTP client such as FileZilla or cPanel.
- Create a note on your computer
- Open it with any text editor and paste the default htaccess code in it:
# 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]
</IfModule>
# END WordPress
- Then rename your file to 1.htaccess
- Open FileZilla, on the right window you can see your root directory
- Move your 1.htaccess to your root directory
- Rename your file to .htaccess
To create this file from your cPanel, follow the steps of creating a notepad and pasting the code in it, and then simply head over to your cPanel > File Manager and locate your public_html then move your 1.htaccess file there and rename it to .htaccess and you have manually created your file.
Conclusion
Having the knowledge to create and manage your WordPress files is the key to having a successful business website. htaccess file can be the beginning of your journey. Because it’s not complicated and at the same time very useful.
It is recommended to backup your website before you make any changes to your website and files.