WordPress Default Htaccess File – Replace Yours When You Run Out at Editing

Well,  as the title says, this is just to share the default Htaccess file to use or replace, when you run out with errors while trying to work with URL redirects or Trailing Slash Modifications or even Extension Hiding. Once things goes wrong, and it is saved, there is no way  to make the site up from the WordPress Admin area, and things can be setup only from the backdoor of the site, i.e from the hosting account only. So, once if you are sure that a corrupted htaccess file is playing the bad game, simply login to the hosting account and replace the htaccess file with the file provided below. I hope that would save you little time finding the htaccess file from the script and uploading it, so i have made the work easier, just download the file below and upload.

Download : Htaccess

Instead here is the code :

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule . /index.php [L]

# END WordPress

Copy Paste it to your notepad and save it in htaccessfile format, and simply upload it to the wordpress base diretory, and its Done.

2 Responses to “WordPress Default Htaccess File – Replace Yours When You Run Out at Editing”

  1. The default WordPress .htaccess code is very non-optimum. With the -f and -d "exists" checks appearing first in the list, every URL request arriving at the server will result in at least two very slow physical disk reads to see if the URL resolves to an existing file. Since every page consists of multiple stylesheet and image requests, there could be several dozen very slow -f and -d "exists" checks for every page requested.

    Since URLs for images and stylesheets are never going to be internally rewritten to the index.php script, all of those requests should simply be rejected for rewriting by using a RewriteCond that checks the file extension of the URL request. The -f and -d "exists" checks are never required for image or stylesheet requests.

    New code is shown below. In this version, requests for images and stylesheets no longer invoke the slow and inefficient -d and -f "exists" checks. This change dramatically speeds up mod_rewrite processing.

    In the default mod_rewrite code, there is a second similar issue. After a URL request has been rewritten to the index.php script, mod_rewrite is invoked again, and it checks to see if index.php exists as a file or directory using those very slow -f and -d checks again. This is a crazy waste of server resources. Of course it exists! Every time! The problem is solved by adding a negative match RewriteCond checking if the current path is /index.php or not. This change speeds up mod_rewrite processing even more.

    The list of file extensions !\.(gif|jpe?g|png|ico|css|js)$ should be optimised "per site" such that the most requested file extensions are listed first. Additional file extensions can be added, such as .zip, .tar and others, but should only be added if actually used somewhere on the site. Each addition degrades server performance very slightly, so keep the list lean.

    The replacement .htaccess file, shown below, should result in at least a three-fold increase in mod_rewrite processing performance and will lead to longer hard drive life. It may well stave off a server upgrade on a busy site for a very long time.

    # Redirect requests for non-blank, non-canonical hostnames to canonical hostname
    RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    # BEGIN WordPress
    # Except for requests for /index.php and for the most-frequently-requested
    # filetypes that WP cannot generate, rewrite all URL requests which do not
    # resolve to an existing file or directory to the WordPress script filepath
    RewriteCond $1 !^index\.php$
    RewriteCond $1 !\.(gif|jpe?g|png|ico|css|js)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ /index.php [L]
    # END WordPress

  2. error13 June 2, 2013

    useful articles

Leave a Reply