Site icon UnderConstructionPage

How to Fix The White Screen of Death Caused by a Broken Htaccess File

Broken Htaccess File

A faulty htaccess file has reduced your site to a blank, white screen? Don’t panic or worry. You didn’t lose anything permanently. We’ll get your site back online in a matter of minutes. Just keep reading.

The Apache htaccess configuration file controls many features for a website. It’s mostly used to handle redirection rules and to ban bad IPs or bots from accessing the site. For WordPress users, it handles a crucial part of permalinks functionality. Without a doubt, htaccess is a powerful tool that can be used to handle a lot of situations and problems.

Unfortunately, the htaccess file has one big flaw. On most servers and especially shared ones, it shows no debug messages if you make a mistake. It’s either OK, and your site works, or you see a blank screen or the 500 error message with no details. That’s very frustrating and scary for beginners. Making a mistake while editing htaccess reduces your site to a blank screen. It looks scary, but you can get the site back online in minutes by following our advice.

Two types of errors

All htaccess errors fall into just two categories – syntax and logical ones.

Syntax errors are the ones that kill your site. Even one wrong character renders the whole htaccess file useless. It can be a typo, a character you left in by mistake or a piece of code not correctly copy/pasted. However, these errors are easier to fix than logical ones. It’s more than evident when you have a syntax error – the site is dead. You can remove a piece of code, find the bug, fix the typo or use an old htaccess file that works.

Logical errors are much harder to fix. They are usually related to conditional redirecting – if a specific condition is met redirect URL A to URL B. Instead of URL B you mistakenly put in URL C. Everything seemingly works. The site is fine, and some other redirect rules work too. It can take weeks until someone reports the problem and then you have to go through the htaccess file line by line to find the bug because no utility can point you to the problematic rule. To avoid being in the dark if an error is slowly crushing your website, make sure that you’ve got powerful allies like Better Uptime that will monitor your site and let you know if there’s something wrong with your site, with the exact reason on why did it go down.

 

We know you don’t make backups because you think they won’t be needed and like most of us you’re lazy. Unfortunately, when something bad happens we all wish we had a backup. That’s why you should use WP Htaccess Editorit automatically makes backups every time you edit the htaccess file and checks it for errors. It’s free and a real life saver.

Step #1 – find the .htaccess file

If the faulty htaccess file is located in your site’s root folder, and chances are 99% that it is, then you can’t use WordPress or any other PHP script to fix the file. That htaccess file affects the complete website. The only way to edit the file is via FTP, cPanel or some other hosting control panel.

If you’re OK working with FTP and have all the access info – connect to the server. If you prefer working via a control panel, log into it and look for an icon labeled “File Manager” or something similar to that like “File Browser”. On most hosts, cPanel is available on https://yoursite.com:2083 URL.

cPanel is the most popular hosting control panel and it comes with a great file manager

Next step is to locate the problematic htaccess file. If there’s only one website on your hosting package, then you don’t need to worry. The only file you find is the one you need. If you have more than one site, pay attention to find the right folder. You’re looking for the www or public_html folder. Besides the htaccess file, in that folder, there’ll be files like index.php, license.txt, readme.html, and folders wp-content, wp-admin and wp-includes. If you see those, you’re definitely in the right place.

Step #2 – delete the .htaccess file

You read it right – we’ll delete the file. Or to be more precise – rename it. Don’t go wild with the new name. Just append something to the end, like “-broken”. So we go from .htaccess to .htaccess-broken. In both FTP and cPanel renaming is done by right-clicking on the file, choosing the “rename” command and entering the new name.

When opening the cPanel file manager, be sure to enable the “Show Hidden Files (dotfiles)” option

Try opening your site. You’re looking for any result that’s not a blank screen. The site might not look perfect. Some images might be broken, but that’s ok. We’re looking to get away from the white screen of death. You can also try to log in to WordPress. The URL is yoursite.com/wp-login.php.

If you’re still not getting anything on the screen, the cache is probably messing with you. Open an incognito tab and access the site. Hit F12 to open the debug console and then reload with Ctrl+Shift+R.

Still no luck? Assuming that htaccess is the cause of the issue then you didn’t rename the right file. Go back to the file browser and find the right file. If the problem persists, you need to contact your hosting company.

Step #3 – rebuild or restore the .htaccess file

The easiest way to rebuild the default WordPress htaccess file is by opening the WP admin and going to Settings – Permalinks. Then, click “Save Changes”. It doesn’t matter what permalink option you choose as long as it’s not the first, “Plain” one. WordPress creates the default htaccess file in the right location, and your site is as good as new.

# BEGIN WordPress

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

# END WordPress

Content of the default WordPress .htaccess file

The default file does not contain any modification or custom code you put in earlier. You need to copy that code from a backup version of htaccess that works, or from the fault htaccess file you renamed earlier to disable it. If you’re using the fault file make sure to copy one line of code at a time, or one block of code. So, select the code, copy it, paste to the new htaccess file, save and then reload the site. That way when you come to the problematic code, you’ll know which code it is – the last one you copy/pasted.

If you’re using the WP Htaccess Editor (and you should be), it’s impossible to kill the site with a broken htaccess file because the plugin checks the htaccess file before saving it and thus prevents saving it if there are any errors found.

As a second safety measure, Htaccess Editor creates automatic backups for every edit you make and saves them in /wp-content/htaccess-editor-backups/ folder. Every backup file is timestamped to make restoring easier.

One of these methods will surely bring you the solution that you’re looking for, but if you’re keener on letting a plugin handle the situation through resetting the database, customizations. plugins, or a different sector that you suspect is doing damage to your site, then WP Reset might be exactly what you’re looking for. Through resetting the website, you’ll be able to restore everything to default values and identify the problem for an easy solution, while keeping your old environment at hand by creating snapshots. Regardless of your method of approach, it’s important to keep your website healthy and running smoothly, and with these secret weapons by your side, there will be no error remaining in sight!

Exit mobile version