.htaccess is a configuration file used on servers running Apache and has many uses, including redirections, custom error pages, forcing HTTPS, allowing or denying specific IP addresses, and much more.
WordPress requires a specific block of code in order for pages to load properly. When the .htaccess file is missing or does not contain the correct information, your website may display a redirect error or pages may show a 404 error. Here we detail the steps to create a new .htaccess file for your WordPress site.
Relate Articles
Getting Started with cPanel
Create File in File Manager
Show Hidden Files in File Manager
Find the Document Root of a Domain
Rename File or Folder in File Manager
Create .htaccess file
- Log into cPanel
- Navigate to File Manager, located under the Files section
- Navigate to the document root of the website for which an .htaccess file is needed
- If an .htaccess file already exists, create a backup of it by renaming it
EXAMPLE: Rename to ".htaccess.bak"
NOTE: As .htaccess starts with a "." it is a hidden file, so you will need to ensure hidden files are shown. See the guide on showing hidden files for instructions. - Create a new file and name it .htaccess
- Right-click the new .htaccess file and click Edit
- Copy and paste the following code to the new .htaccess file then click the Save Changes button:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress