Quantcast
Channel: ImproveSeo.info » Improve Speed
Viewing all articles
Browse latest Browse all 8

How to optimize WordPress .htaccess file

$
0
0

It is known the importance of the page loading speed over the traffic of your blog. Recently there were a lot of discussions and probably the page loading speed will become an important SEO factor for google and other search engines.

The main problem with the existing .htaccess file is that the RewriteCond directives checks the existence of a file on disk when it is not really required. Each access to disk increase the page loading time.

# BEGIN WordPress

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

# END WordPress

Currently the wordpress .htaccess is not optimized at all. In a post on Webmaster World, Jim Morgan who is a Mod_Rewrite/.htaccess guru, suggest replacing the existing .htaccess with a more efficient one:

# BEGIN WordPress
RewriteEngine on
#
# Unless you have set a different RewriteBase preceding this
# point, you may delete or comment-out the following
# RewriteBase directive:
RewriteBase /
#
# if this request is for "/" or has already been rewritten to WP
RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 \.(gif|jpg|css|js|ico)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]
#
# END wordpress

Here are the optimizations the previous code implements:
it is useless to check the existence of index.php, because it is there. This will avoid useless file checkings for requests to example.com, example.com/ or example.com/index.php.
each request to static instances is not really required to be redirected. If the file is on disk it will be served otherwise an file not found or default subdirectory index.php file will be returned. This would include all the .jpg,.png,.gif,.css,.js and other static files. Since most of the blogs contains lots of static file this would have a huge impact.

Source: http://wordpress.org/extend/ideas/topic.php?id=3524

Related Posts


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images