How to Fix Corrupted htaccess - Detailed Guide

How to Fix Corrupted htaccess – Detailed Guide

Are you receiving a 403 error, due to a corrupt in htaccess? Our detailed guide will definitely be of help for you to fix corrupted htaccess file and clearing this pesky error, so you can have a safe and happy experience while using WordPress and editing htaccess for the future, without experiencing any corruptions in htaccess.

What is the htaccess file?

The htaccess file stands for hypertext access, which means that it is a server configuration file. It is one of the most important components, which keeps your WordPress file alive.

With the help of htaccess file you can configurations for specific directories.

For example, you would like to have expires headers on your website, but do not wish to install more plugins, as this may cause serious loading times (even though you had set your caching plugin and optimized your pages and contents for faster loading times).

If you would like to speed up your website and add expires headers to it, you can simply go to the htaccess file and add the following line of code:

<IfModule mod_expires.c>

  ExpiresActive On

  # Images

  ExpiresByType image/jpeg “access plus 1 year”

  ExpiresByType image/gif “access plus 1 year”

  ExpiresByType image/png “access plus 1 year”

  ExpiresByType image/webp “access plus 1 year”

  ExpiresByType image/svg+xml “access plus 1 year”

  ExpiresByType image/x-icon “access plus 1 year”

  # Video

  ExpiresByType video/mp4 “access plus 1 year”

  ExpiresByType video/mpeg “access plus 1 year”

  # CSS, JavaScript

  ExpiresByType text/css “access plus 1 month”

  ExpiresByType text/javascript “access plus 1 month”

  ExpiresByType application/javascript “access plus 1 month”

  # Others

  ExpiresByType application/pdf “access plus 1 month”

  ExpiresByType application/x-shockwave-flash “access plus 1 month”

</IfModule>

Why is my htaccess file corrupted?

It’s not something new and you did not definitely discover hot water if you have a corrupted htaccess file.

The WordPress htaccess file is powering Apache and its role is critical if you lose it, but it is not the end of the world for you, or your website.

To get your htaccess file corrupted, you had:

Downloaded a plugin, which messed it up, by overwriting and destroying an important line.

Changed some functions, which were missing a semicolon, comma or another symbol.

Ignorantly deleted an important line, which was holding your website.

Added a new code, which had overwritten the main functions.

Had a sudden stop in your localhost or web host, which can lead to stopping the process of overwriting and leading to a corrupted htaccess file.

A normal htaccess file, which isn’t corrupted should look like this:

# 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

How to fix corrupted htacces file?

In my personal experience, I had heard that you will need to disable each plugin and see if that fixes the error.

Well that is definitely true!

Imagine that your htaccess file was fine before downloading a plugin and you are sure about it.

You will again receive a corrupted htaccess file and will have to start the whole process once again.

Fixing the corrupted htaccess file by disabling plugins

Here is how you can start and see if the corrupted htaccess file is coming from a plugin. Try disabling each plugin one by one. After having all of your plugins disabled, see if the corrupted htaccess file problem still persists.

If you have no more problems with the htaccess file, then start re-enabling each plugin along with refreshing. If you have two plugins, which are doing the same thing, you should consider removing one of them, which can be a fix of the corrupted htaccess file problem that you are having.

Another problem can be a bad plugin, which is not well set or probably cracked/nulled.

In my personal experience I would not recommend using such plugins or themes, as they will not help your website. They will completely destroy it.

After you have found the plugin, which is causing the corruption of the htaccess file, simply delete it and search for an alternative to this plugin, which will not cause problems with the htaccess.

Fixing the corrupted htaccess file by deleting and creating a new htaccess file

The corruption of the htaccess file, as mentioned before, can come from the disconnection of the internet through your web host or local host.

This may cause missing codes and functions, which htaccess needs in order to spread the rules along to all the other files and maintain a nice operation.

In order to fix the corrupted htaccess file, you will need to go to your cPanel and access the file manager.

How to Fix Corrupted htaccess - Detailed Guide - cPanel
CPanel design in 2021. Your panel may differ, but have the same elements

After this go to your public_html file and there you will be able to see .htaccess file.

How to Fix Corrupted htaccess - Detailed Guide - File manager
Inside the File Manager

Delete the htaccess file and navigate to your WordPress website.

Go to your permalinks tab and all you have to do is click on “save changes”.

You do not need to change anything or rewrite your custom permalinks etc.

After saving your changes, a new htaccess file will be set in your public_html folder and it should fix the problem with having a corrupted htaccess file.

Fixing the corrupted htaccess file by a backup of the website

Having website backups is a must, when you are owning a website. It is like keeping a spare pen for writing.

Backups can be done through plugins such as UpDraftPlus, BackWPup, Duplicator, BackupBuddy and etc.

These plugins are not good only when you have to fix corrupted htaccess files. They can save your life even when something else crashes on your website.

It is even time saving, if you are writing blogs every day like me.

Fixing the corrupted htaccess file by a backup from your web host

If you cannot find the problem with the htaccess file, while you had tried every other thing that was mentioned and did not have a backup, your best shot is your web hosting company.

Web hosting companies are creating a backup of your website every day, every two days or more. It all really depends on your website, but choosing the right hosting, which can back you up at any time, should be your choice.

In order to retrieve a backup, you could do it manually, in your cPanel, by navigating to backups and choose the date of the backup.

If you would like your web host to do a backup, you will have to speak with them.

Simply ask them if they could perform a backup, which will revert your website 24 hours back (if they have one) or maybe an older one.

You can ask them this way

Hello,

I hope you are doing well and having a nice day.

The reason I am writing to you is something hard for me to fix.

I am having a problem with a corrupted htaccess file and cannot fix it on my own.

Could you please perform a backup on my website, so I can fix my problem with the corrupted htaccess.

Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *