Looking for the most common WordPress .htaccess file and reset it to its defaults?

Sometimes you will need to alter your WordPress site to accommodate custom behaviors, custom folders, and rewrite handlers for certain scripts.  Things might start acting weird, so what do you do?  You, or someone from your team has probably altered something in the .htaccess file.  Rename the existing one to “htaccess.txt” then create a new file called .htaccess and paste these lines in the file and reupload it to your web root folder (usually in /public_html/):

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

When you get the “white screen of death” on a WordPress site, this is one of your usual suspects.  Often, when someone runs WordPress from a subfolder instead of the root of your website (like installing WordPress in /public_html/wordpress/) some developers may believe they need to alter the .htaccess in order for WordPress to operate, be seen, and show files to omit the /wordpress/ trailing path.  This is not the case, however, the handling of paths and sub paths all go back to the fact that WordPress, like many frameworks and websites designed with the MVC pattern, all run off a single index.php that is located in the root directory.  No matter what pages or scripts you run, WordPress treats them as if they are being run from the web root.

Here is a diagram that may help you understand the basic structure of WordPress code.  It is oversimplified but it should help you visualize how WordPress is organized under the hood:


Open the index.php file WordPress runs on, notice in the configuration instructions you have to update the path to wp-blog-header.php by prepending it with the subfolder WordPress is contained in?  That’s why.  Since the index.php file in your web root folder is the file that loads all other files, your code always knows where “root” and “home” is.  This makes it much easier to navigate and organize your code without worrying about sub paths and relative paths.  If you imagine your code is organized much like a pyramid where, at the top is always this main index.php file handler, you will be able to better understand how WordPress works so you can more effectively troubleshoot problems later.

About Author:

Senior Cloud Software Engineer and 25+ years experienced video production, video editing and 3D animation services for a variety of global clients including local video production here in Jacksonville, Florida.

Leave a Comment

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