1. Home
  2. Knowledge Base
  3. SEO Suite
  4. How to Edit Your htaccess File Using Rank Math

How to Edit Your htaccess File Using Rank Math

The .htaccess file is a configuration file that helps you configure redirections, modify HTTP headers and more. Rank Math makes it easier for you to edit your .htacess file right inside your WordPress dashboard.

In this knowledgebase article, we will walk you through how to edit your website’s .htaccess file using Rank Math, and in case of any issues with the changes made, how to restore the .htaccess file from the backup.

Editing htaccess File

Let’s take a look at how you can edit your .htaccess file using Rank Math.

Note: Make sure your firewall or security plugin is setup to whitelist Rank Math. Otherwise, it might block the edits made using Rank Math. You can talk to your web host about this.

1 Navigate to Edit htaccess

In order to edit your .htaccess file, go to Rank Math > General Settings > Edit .htaccess. If this section is not available on your website, then ensure that you’ve switched to the Advanced Mode in Rank Math.

Edit .htaccess in Rank Math

2 Make Changes to htaccess

Inside this section, you will notice that there is a single text area that can be used to edit the .htaccess file. Please be careful and do read the warning above the text area before you edit the .htaccess file.

The notice warns you that changing the .htacess file can harm your website. Even if you are technically capable, you are bound to make mistakes. To prevent issues, Rank Math automatically backs up your .htacess before you modify it.

If you want to edit the .htacess file, then click the checkbox below the text. The text area below will become active, and you can then edit your .htacess file.

Edit .htaccess file in Rank Math

3 Save Changes

When you’re done making all of your changes, click Save Changes and check if the expected changes are reflected on your website.

Restore htaccess Backup

In case, after saving the changes, if you cannot access your website, that means something went wrong, and you need to restore the backup, by following the steps discussed below.

1 Access Your Website Files

Now to fix the issue, log in to your website using FTP or cPanel File Manager. At the root of your website, you can notice a .htaccess file and a backup file named .htaccess-back-XXXXX.

.htaccess and backup file

2 Delete the Existing file

Now delete the existing .htaccess file. (You can also download a copy of the .htaccess file saved to your computer before deleting, in case, if you want to analyze what went wrong).

Delete .htaccess file

3 Restore the backup file

Now that you’ve deleted the .htaccess file, you can rename .htaccess-back-XXXXX to .htaccess.

Rename htaccess backup file to htaccess

Once you’ve renamed the file, you can check if your website can be accessed now.

How to Fix htaccess File Not Found Error?

In case, if you’re seeing the error “.htaccess file not found”, it is because Rank Math is unable to find the .htaccess file at the root of your website. If you wish to edit .htaccess with Rank Math, then you would need to create one at the root of your website.

.htaccess file not found

1 Create .htaccess file

You can create a .htaccess file using FTP or cPanel File Manager by following the steps discussed below.

Note: If you’re unable to add the .htaccess file directly, please reach out to your web host, as they would be able to add this for you.

FTP:

If you’re using FTP, then access the root of your website file. And then right-click to Create New File in the root of your website.

Create new file in FTP

Name the newly created file as .htaccess, as shown below.

Create htaccess file in FTP

cPanel File Manager:

If you’re using cPanel File Manager, then in the root of your website’s directory, click the New File button available at the top-left corner.

Create a new file in File Manager

In the popup that appears on your screen, enter the name of the file as .htaccess and then choose Create New File option.

Create htaccess file in cPanel File Manager

2 Add the Code

Next, navigate to Edit .htaccess under Rank Math > General Settings inside your WordPress dashboard and then add the following code to the .htaccess file, in the same way, we discussed earlier in this tutorial.

Please note, the below code is standard for all basic WordPress sites to allow WordPress to manage your permalinks. If you’re using multisite, then you can refer to the code provided in the official WordPress documentation.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Now click Save Changes at the bottom of the screen, and now you can start making changes to your website’s .htaccess file with Rank Math.

And that’s it! If you have any other questions about editing your .htaccess file with Rank Math – don’t hesitate to reach out to our support team, and we’re always here to help.

Was this article helpful?

Still need help?

?

Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket

Related Articles