You are here: Home / kb / How to Configure your .htaccess file for WordPress

How to Configure your .htaccess file for WordPress


The .htaccess is an essential core file within WordPress. In essence it enables permalink functions, you can also customise your .htaccess file to carry out many other things from speeding up your WordPress site, to security and performing redirects.

The essential configuration file used on an Apache server can be found in the ‘root’ section of your account.

The essential code for your .htaccess file necessary for WordPress is as follows:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Locating Your .htaccess file in your WordPress Installation


Firstly login to your cPanel account using either through the client area or using your login details.

Once logged in go to Files --> File Manager

select file manager in cpanel

Then double click the public_html directory

The default setting within cPanel is that all dot files are hidden. Therefore, if you don’t see the htaccess file you will need to check the file is not hidden. To do this:

Click Settings (top right hand corner)

settings in cpanel

This brings up the ‘Preferences’ dialogue box. Just select the checkbox ‘Show Hidden Files (dotfiles)’. Then simply click ‘Save’ and the page will reload, and it should now display your .htaccess file.

Create a New .htaccess file in cPanel


If you have migrated your website from another host to Cheap Host and for some reason you are missing the htaccess file, you will need to create it to ensure your WordPress installation works correctly.

From within your cPanel account in the public_html directory:

Select ‘+ File’ in the top left of your screen

create a new file in cpanel

And then type .htaccess and ‘Create New File’

The page will then reload, and you will see your htaccess file has been created. It will usually be directly underneath the ‘wp-includes’ folder.

htaccess file in file manager cpanel

If you want to then add the necessary WordPress .htaccess code at the top of the page simply highlight the .htaccess file using the left mouse button and click ‘Edit’ from the top menu options. Click ‘edit’ again when the dialogue box appears and then copy the following code:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Now simply click ‘Save Changes’ at the top right hand corner of the page, and that's it all done!

404 Error in WordPress After Site Migration


One of the most common causes of a ‘404 error’ after moving your website to Cheap Host, is that your .htaccess file is now. missing from your installation. This is because the .htaccess file controls the permalink structure within your website, and so the homepage may load, but you will get the 404 error when you try to load another page within your website. If you get this error, please follow the instructions above to ‘Create a New .htaccess file’ above.

Call Now Button