<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Digging into WordPress &#187; performance</title>
	<atom:link href="http://digwp.com/tag/performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:03:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>6 .htaccess Tricks for Better WordPress SEO &amp; Security</title>
		<link>http://digwp.com/2011/03/htaccess-wordpress-seo-security/</link>
		<comments>http://digwp.com/2011/03/htaccess-wordpress-seo-security/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 23:59:08 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[HTAccess]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=3712</guid>
		<description><![CDATA[Here are six htacccess tricks that will help improve the security and SEO quality of your WordPress-powered site. We do this using .htaccess to establish canonical URLs for key peripheral files, such as your robots.txt, favicon.ico, and sitemap.xml files. Canonicalization keeps legitimate bots on track, eliminates malicious behavior, and ensures a better user-experience for everyone. [...]]]></description>
			<content:encoded><![CDATA[<p>Here are <strong>six htacccess tricks</strong> that will help improve the security and <abbr title="Search Engine Optimization">SEO</abbr> quality of your WordPress-powered site. We do this using .htaccess to establish <strong>canonical <abbr title="Uniform Resource Locator">URL</abbr>s</strong> for key peripheral files, such as your <code>robots.txt</code>, <code>favicon.ico</code>, and <code>sitemap.xml</code> files. Canonicalization keeps legitimate bots on track, eliminates malicious behavior, and ensures a better user-experience for everyone. On the menu:</p>
<p><span id="more-3712"></span></p>
<ol>
<li><a href="#canonical-robots">Canonical robots.txt</a></li>
<li><a href="#canonical-favicons">Canonical Favicons</a></li>
<li><a href="#canonical-sitemaps">Canonical Sitemaps</a></li>
<li><a href="#canonical-urls">Canonical Category, Tag &amp; Search URLs</a></li>
<li><a href="#canonical-feeds">Canonical Feeds</a></li>
<li><a href="#canonical-login">Simpler Login URL</a></li>
</ol>
<h3>Before making changes..</h3>
<p>The .htaccess code in this post is designed to work when placed in the web-accessible root .htaccess file of your domain. Before making any changes to this file, make a good backup and keep it on hand just in case. Working with .htaccess is nothing to be afraid of, but it&#8217;s <em>critical</em> to not make any mistakes in syntax, spelling, or anything that&#8217;s not a comment (<code>#</code>). If you forget a dot working with <abbr title="Cascading Style Sheets">CSS</abbr>, your design might look messed up. If you forget a dot working with .htaccess your server will return a <strong>500 &ndash; Internal Server Error</strong>. If this happens, <em>don&#8217;t panic</em>, just upload your backup and everything will be fine.</p>
<h3 id="canonical-robots">1. Canonical robots.txt</h3>
<p>Help bots and visitors find your <code>robots.txt</code> file no matter what. Given that the <code>robots.txt</code> file should always be located in the root directory, you would <em>think</em> that this wouldn&#8217;t be an issue. Unfortunately, bad bots and malicious scripts like to scan for <code>robots.txt</code> files <a href="http://perishablepress.com/malicious-server-scans/" title="What a Malicious Server Scan Looks Like">everywhere</a>. Fortunately, this .htaccess snippet eliminates the nonsense by directing any request for &#8220;robots.txt&#8221; to the actual file in your root directory. If you&#8217;re sick of seeing endless requests for nonexistent robots files, this code&#8217;s for you:</p>
<pre><code># CANONICAL ROBOTS.TXT
&lt;IfModule mod_rewrite.c&gt;
 RewriteBase /
 RewriteCond %{REQUEST_URI} !^/robots.txt$ [NC]
 RewriteCond %{REQUEST_URI} robots\.txt [NC]
 RewriteRule .* http://example.com/robots.txt [R=301,L]
&lt;/IfModule&gt;</code></pre>
<p>To use this code, replace <code>example.com</code> with your own domain and include in your web-accessible root directory. These directives collectively redirect all requests for any &#8220;robots.txt&#8221; file, with the exception of the actual, root robots.txt file. If you need to whitelist a similarly named file, just include the following line beneath the first <code>RewriteCond</code>, replacing the path and file name with your own:</p>
<p><code>RewriteCond %{REQUEST_URI} !/wordpress/robots.txt$ [NC]</code></p>
<p><strong>Alternate Method:</strong> Instead of using Apache&#8217;s <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html" title="Apache Module mod_rewrite">rewrite module</a>, we can do the <a href="http://perishablepress.com/press/2009/05/11/htaccess-spring-cleaning/" title="HTAccess Spring Cleaning 2009">same thing with less code</a> using <a href="http://httpd.apache.org/docs/current/mod/mod_alias.html" title="Apache Module mod_alias">mod_alias</a>:</p>
<p><code>RedirectMatch 301 ^/(.*)/robots\.txt http://example.com/robots.txt</code></p>
<p>Either method is effective, but <code>mod_alias</code> is optimal for typical sites with only one robots.txt file. If you have multiple robots.txt files, the <code>mod_rewrite</code> method will enable complete granular control from the root .htaccess file.</p>
<h3 id="canonical-favicons">2. Canonical Favicons</h3>
<p>Avatars, gravatars, and favicons are a big hit with malicious scanners. Evil scripts like to traverse your directory structure with requests for commonly used images such as the ubiquitous <code>favicon.ico</code>. So just as with <code>robots.txt</code>, we can <a href="http://perishablepress.com/press/2008/08/11/block-favicon-url-404-requests/" title="Stop the Madness: Redirect those Ridiculous Favicon 404 Requests">stop the madness</a> and <a href="http://perishablepress.com/press/2008/08/12/redirect-all-requests-for-a-nonexistent-file-to-the-actual-file/" title="Redirect All Requests for a Nonexistent File to the Actual File">redirect any request for &#8220;favicon.ico&#8221; to the actual file</a> in your root directory.</p>
<pre><code># CANONICAL FAVICONS
&lt;IfModule mod_rewrite.c&gt;
 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_URI} !^/favicon.ico$ [NC]
 RewriteCond %{REQUEST_URI} /favicon(s)?\.?(gif|ico|jpe?g?|png)?$ [NC]
 RewriteRule (.*) http://example.com/favicon.ico [R=301,L]
&lt;/IfModule&gt;</code></pre>
<p>To use this code, replace <code>example.com</code> with your own domain and include in your web-accessible root directory. These directives collectively redirect all requests for any &#8220;<code>favicon</code>&#8221; or &#8220;<code>favicons</code>&#8221; with a <code>.png</code>, <code>.gif</code>, <code>.ico</code>, or <code>.jpg</code> extension. To prevent an infinite request loop, the code includes an exception for the actual, root &#8220;<code>favicon.ico</code>&#8221; file. If you need to whitelist a similarly named file, just include the following line beneath the first <code>RewriteCond</code>, replacing the path and file name with your own:</p>
<p><code>RewriteCond %{REQUEST_URI} !/images/favicons.png$ [NC]</code></p>
<h3 id="canonical-sitemaps">3. Canonical Sitemaps</h3>
<p>Just as idiotic bots can&#8217;t seem to find your robots and favicon files, so too are they clueless when it comes to finding your sitemap, even when declared in the robots.txt file. Nefarious bots will ignore your robots suggestions and hammer your site with ill-requests for nonexistent sitemaps. This malicious behavior chews up system resources and wastes bandwidth. To eliminate the waste while helping stupid bots find your sitemap, slip this into your root .htaccess:</p>
<pre><code># CANONICAL SITEMAPS
&lt;IfModule mod_alias.c&gt;
 RedirectMatch 301 /sitemap\.xml$ http://example.com/sitemap.xml
 RedirectMatch 301 /sitemap\.xml\.gz$ http://example.com/sitemap.xml.gz
&lt;/IfModule&gt;</code></pre>
<p>To use this code, edit each rule with your own domains and file paths. The first rule redirects all requests for your regular, uncompressed sitemap, and the second rule redirects all requests for your compressed (gzipped) sitemap. These rules are independent of each other, so feel free to remove either to suit your needs.</p>
<h3 id="canonical-urls">4. Canonical Category, Tag, and Search URLs</h3>
<p>Out of the box, WordPress returns a <strong>404 &ndash; Not Found</strong> for the following URLs:</p>
<ul>
<li><code>http://your-domain.tld/blog/tag/</code></li>
<li><code>http://your-domain.tld/blog/search/</code></li>
<li><code>http://your-domain.tld/blog/category/</code></li>
</ul>
<p>These are commonly requested URLs that may be leaking valuable page rank. As <a href="http://digwp.com/2009/06/redirect-category-search-and-tag-urls/" title="Redirect Dead-End Category, Search and Tag URLs">explained previously</a>, you can use the following slice of .htaccess to redirect these URLs to your home page (or anywhere else):</p>
<pre><code># CANONICAL URLs
&lt;IfModule mod_alias.c&gt;
 RedirectMatch 301 ^/tag/$      http://example.com/
 RedirectMatch 301 ^/search/$   http://example.com/
 RedirectMatch 301 ^/category/$ http://example.com/
&lt;/IfModule&gt;</code></pre>
<p>To use, place the previous code into your root .htaccess file and replace each <code>example.com</code> with the desired redirect location. Alternately, if WordPress is <a href="http://digwp.com/2009/07/move-your-wordpress-files-out-of-the-root-directory/" title="Move Your WordPress Files Out of the Root Directory">installed in a subdirectory</a>, use this code instead:</p>
<pre><code># CANONICAL URLs
&lt;IfModule mod_alias.c&gt;
 RedirectMatch 301 ^/blog/tag/$      http://example.com/
 RedirectMatch 301 ^/blog/search/$   http://example.com/
 RedirectMatch 301 ^/blog/category/$ http://example.com/
&lt;/IfModule&gt;</code></pre>
<p>Again, edit the examples with your actual URLs. A good place to redirect any juice or traffic from these three URLs is the home page. Hopefully future versions of WordPress will handle these redirects internally, but until then, this bit of .htaccess is a simple and effective solution.</p>
<h3 id="canonical-feeds">5. Canonical Feeds</h3>
<p>WordPress generates many <a href="http://perishablepress.com/press/2008/03/09/what-is-my-wordpress-feed-url/" title="http://perishablepress.com/press/2008/03/09/what-is-my-wordpress-feed-url/">different feeds for your site</a>. The default feed configuration works great, but it&#8217;s worth including in this post a couple of useful .htaccess tricks:</p>
<ul>
<li>Set up canonical feed types (e.g., deliver only RSS2 feeds and redirect other formats)</li>
<li>Setup FeedBurner feeds and redirect associated feed requests</li>
</ul>
<p>Each of these techniques are easily achieved with a little .htaccess. Better grab a beverage..</p>
<h4>Set up canonical feeds</h4>
<p>WordPress provides feeds in four different formats: Atom, RDF, RSS, and RSS2. This variety was useful in the past to accommodate different apps and devices, but these days I think it&#8217;s safe to say that most readers and devices can handle any format you throw at it. So instead of having 4x the feeds, you can consolidate your feeds into a single format:</p>
<pre><code># CANONICAL FEEDS
&lt;IfModule mod_alias.c&gt;
 RedirectMatch 301 /feed/(atom|rdf|rss|rss2)/?$ http://example.com/feed/
 RedirectMatch 301 /comments/feed/(atom|rdf|rss|rss2)/?$ http://example.com/comments/feed/
&lt;/IfModule&gt;</code></pre>
<p>This code will redirect requests for alternate feed formats to your canonical choice for both main-content feed and all-comments feed. To use this code, replace both of the target URLs with your own and place in the web-accessible root directory.</p>
<h4>Redirect feeds to FeedBurner</h4>
<p>Redirecting feeds to FeedBurner is another useful .htaccess snippet to have in your tool belt. Here are two snippets to do the job &ndash; one for main-content and another for all-comments feeds:</p>
<pre><code># REDIRECT to FEEDBURNER
&lt;IfModule mod_rewrite.c&gt;
 RewriteCond %{REQUEST_URI} ^/feed/ [NC]
 RewriteCond %{HTTP_USER_AGENT} !(FeedBurner|FeedValidator) [NC]
 RewriteRule .* http://feeds.feedburner.com/mainContentFeed [L,R=302]

 RewriteCond %{REQUEST_URI} ^/comments/feed/ [NC]
 RewriteCond %{HTTP_USER_AGENT} !(FeedBurner|FeedValidator) [NC]
 RewriteRule .* http://feeds.feedburner.com/allCommentsFeed [L,R=302]
&lt;/IfModule&gt;</code></pre>
<p>The first block redirects all requests for your main-content feed, and the second block handles your all-comments feed. So to use, just replace the <code>mainContentFeed</code> and <code>allCommentsFeed</code> with the URLs of your associated FeedBurner feeds. You may also redirect special category feeds by replicating the pattern with another block of code:</p>
<pre><code> RewriteCond %{REQUEST_URI} ^/category/wordpress/feed/ [NC]
 RewriteCond %{HTTP_USER_AGENT} !(FeedBurner|FeedValidator) [NC]
 RewriteRule .* http://feeds.feedburner.com/specialCategoryFeed [L,R=302]</code></pre>
<p>As before, just replace the URL of your FeedBurner feed in the <code>RewriteRule</code> and test accordingly.</p>
<h3 id="canonical-login">6. Simpler Login URL</h3>
<p>Lastly, a cool .htaccess trick for a <a href="http://digwp.com/2011/01/simpler-login-url/" title="Simpler Login URL">better user-login</a> experience. A single line of code placed in your root .htaccess file is all it takes:</p>
<pre><code>RewriteRule ^login$ http://example.com/wp-login.php [NC,L]</code></pre>
<p>Edit the <code>example.com</code> with the domain/path of your WordPress installation. Now instead of typing &ldquo;<code>wp-login.php</code>&rdquo;, we just type &ldquo;<code>login</code>&rdquo; and whoop, there it is.</p>
<p>You could also use <code>RedirectMatch</code> to enable a login URL switch:</p>
<p><code>RedirectMatch 301 \@admin http://example.com/wp-admin</code></p>
<p>The <code>@</code> prevents the rule from bothering anything else, and <code>RedirectMatch</code> picks up on the switch from anywhere in the site, so regardless of what page you’re on, you just append &ldquo;<code>@admin</code>&rdquo; to the URL and you’re there. I use this trick at <a href="http://perishable.biz" title="Cool graphics &#038; stuff">http://perishable.biz</a> if you want to see it work. Check the comments of <a href="http://digwp.com/2011/01/simpler-login-url/" title="Simpler Login URL">Chris&#8217; original post</a> for good discussion and some more great ideas.</p>
<hr />
<p><small>© 2011 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2011/03/htaccess-wordpress-seo-security/">Permalink</a> | <a href="http://digwp.com/2011/03/htaccess-wordpress-seo-security/#comments">20 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2011/03/htaccess-wordpress-seo-security/&title=6 .htaccess Tricks for Better WordPress SEO &amp; Security">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/htaccess-2/" rel="tag">htaccess</a>, <a href="http://digwp.com/tag/performance/" rel="tag">performance</a>, <a href="http://digwp.com/tag/seo/" rel="tag">SEO</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2011/03/htaccess-wordpress-seo-security/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Pimp your wp-config.php</title>
		<link>http://digwp.com/2010/08/pimp-your-wp-config-php/</link>
		<comments>http://digwp.com/2010/08/pimp-your-wp-config-php/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 18:52:39 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2416</guid>
		<description><![CDATA[Easily, the most important file in your WordPress installation is the wp-config.php file. It serves as your site&#8217;s base configuration file, controlling key aspects of WordPress&#8217; functionality and enabling WordPress to do mission-critical stuff like connect to the database. Without wp-config.php, WordPress simply won&#8217;t work. So whenever you install WordPress, one of the first things [...]]]></description>
			<content:encoded><![CDATA[<p>Easily, the most <em>important</em> file in your WordPress installation is the <code>wp-config.php</code> file. It serves as your site&rsquo;s <strong>base configuration file</strong>, controlling <em>key aspects</em> of WordPress&rsquo; functionality and enabling WordPress to do mission-critical stuff like connect to the database. Without <code>wp-config.php</code>, WordPress simply won&rsquo;t work. So whenever you install WordPress, one of the <em>first</em> things to do is pimp your <code>wp-config.php</code>.</p>
<p>And it&rsquo;s pretty easy too &ndash; just get your database credentials in place and you&rsquo;re done. The other settings available in the <code>wp-config.php</code> file will work just fine using the default values, but there are some <em>cool things</em> you can do to customize functionality, tighten security, and improve performance. Once you get the basics of <code>wp-config.php</code>, you can really <em>pimp it out</em> to do some awesome stuff. We&rsquo;ll break this down into <strong>four basic parts</strong>:</p>
<ul>
<li><a href="http://digwp.com/2010/08/pimp-your-wp-config-php/#basics" title="There is no wp-config.php..">Basics</a></li>
<li><a href="http://digwp.com/2010/08/pimp-your-wp-config-php/#security" title="Protect wp-config.php">Security</a></li>
<li><a href="http://digwp.com/2010/08/pimp-your-wp-config-php/#settings" title="Main Configuration Settings">Main Settings</a></li>
<li><a href="http://digwp.com/2010/08/pimp-your-wp-config-php/#pimpin" title="Pimp it out!">Additional Tips and Tricks</a></li>
</ul>
<p><span id="more-2416"></span></p>
<h3 id="basics">There is no wp-config.php..</h3>
<p>When you first download WordPress, the <code>wp-config.php</code> file isn&rsquo;t included. Instead, you get a file named &ldquo;<code>wp-config-sample.php</code>&rdquo; (located in the root install-directory) that contains everything you need. Just rename the file to &ldquo;<code>wp-config.php</code>&rdquo; and delete the <code>wp-config-sample.php</code> file from the server if it&rsquo;s already there. Here is a visual:</p>
<p><img src="http://digwp.com/wp-content/blog-images/wp-config-01.jpg" alt="[ Rename the file ]" /></p>
<p>With the <code>wp-config.php</code> file now ready to go, it&rsquo;s time to protect it..</p>
<h3 id="security">Protect wp-config.php</h3>
<p>The first thing you want to do with <code>wp-config.php</code> is protect it. Here is a great way to secure the file using .htaccess:</p>
<pre><code>&lt;Files wp-config.php&gt;
	Order Allow,Deny
	Deny from all
&lt;/Files&gt;</code></pre>
<p>This code should be placed in an .htaccess file located in the directory that contains your <code>wp-config.php</code> file.</p>
<p><img src="http://digwp.com/wp-content/blog-images/wp-config-02.jpg" alt="[ Use the same directory ]" /></p>
<p>Once the .htaccess file is in place, ensure that permissions are <abbr title="change mode">chmod</abbr> <strong>640</strong> for both files. This setting returns a &ldquo;403 Forbidden&rdquo; error to all external requests. Combining proper file permissions with .htaccess protection is an excellent way to <em>secure</em> your <code>wp-config.php</code>.</p>
<h3 id="settings">Main Configuration Settings</h3>
<p>Now that <code>wp-config.php</code> is secure, it&rsquo;s time to add the required database information and then customize for optimum performance. This section covers the first four configuration settings that you&rsquo;ll find <em>already included</em> in your <code>wp-config.php</code>. Then in the next section, we&rsquo;ll explore some awesome techniques and really pimp things out.</p>
<h4>1) Database credentials</h4>
<p>The first and only <em>required</em> step is to add your database credentials. This should appear after the PHP comments near the top of the file:</p>
<pre><code>// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');</code></pre>
<p>For most servers, you&rsquo;ll need only the first three bits of information: database name, username and password. If WordPress can&rsquo;t connect after that, then you may need to change the hostname to whatever your host tells you. Only fiddle with the last two items &ndash; charset and collate &ndash; if you have need and know what you&rsquo;re doing.</p>
<h4>2) Authentication Unique Keys and Salts</h4>
<p>Next up is a section for key/salt definitions. By default it looks like this:</p>
<pre><code>/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

/**#@-*/</code></pre>
<p>The eight definitions should be replaced with values generated via the official <a href="https://api.wordpress.org/secret-key/1.1/salt/">WordPress.org secret-key service</a>. Visit that link, refresh the page a few times, and paste the results into place, like so:</p>
<pre><code>/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         ')` 4yDGc w=*:l8@RD167k0+/+@+rgo(mI-x&lt;_~.=WtCm[qD8&lt;3S)TsR}K~bMLNT');
define('SECURE_AUTH_KEY',  'zO?htRkV.k[vBqn&lt;+.,lorpObkc?@|Vi+8`w=A9,|FjPB&amp;5`5|9&lt;[&amp;&amp;WaUB.pwTS');
define('LOGGED_IN_KEY',    'jtr|J-/.-:6CVh*8h.~bNzc3^#A9@hB9G3E/fx/&gt;k)pmTHbES5^Rq(+EINCW w&gt;8');
define('NONCE_KEY',        'O2Vz+br+`6MqQVv1{-g}sy -CF8M/tldEyWV[W}dnebd7m$6.P,m+.G6Ec]{V@Kl');
define('AUTH_SALT',        '&gt;x,, 8wMLIJCH}i94Ib+}~lR%r_))x@LU3~YJwCok++xaSVE@[My(zAg!Fpi4{NR');
define('SECURE_AUTH_SALT', '7[,gAJ#TQmsw:$!R-n-r%4&lt;UvG7%|-7&amp;jt4]XS-[KX&amp;O)|H,err]&lt;{EuFnmP3,M}');
define('LOGGED_IN_SALT',   '9dJP8uW2E2&amp;.^a|@I|[?qbY%z:&amp;jgnH&lt;OUg+t6Tks,Hox=M@~yx+b;~zU)436q=+');
define('NONCE_SALT',       '=Xv~8+!&gt;l:wy`~w0U-6wO2lmG8l5Xg21$J59T$T~)(h5m&lt;5`|/|dVN{j[80QMV60');

/**#@-*/</code></pre>
<p>Don&rsquo;t use the example keys shown here though &ndash; the whole idea is to specify <em>unique</em> phrases to <em>improve</em> security. And it&rsquo;s totally fine to replace these keys at any time &ndash; the worst that will happen is that currently logged-in users will need to log in again. </p>
<p>At this point, we have our database credentials and secret keys all ready to go. Next we want to <em>further improve security</em> by specifying a unique database prefix.</p>
<h4>3) WordPress Database Table prefix</h4>
<p>WordPress is a <em>huge</em> target for <a href="http://digwp.com/2010/07/wordpress-security-lockdown/#pharma-hack" title="WordPress Security Lockdown">malicious scripts</a>, <a href="http://digwp.com/2010/07/media-temple-wordpress-hack/" title="Media Temple WordPress Hack">hacks</a>, and <a href="http://digwp.com/2009/06/spam-link-injection-hacked/" title="Spam Link Injection Hacked (and How I Hopefully Fixed It)">spam</a>. One of the best ways to secure your WordPress database is to change the default table prefix. The default value, as seen below, is &ldquo;<code>wp_</code>&rdquo;:</p>
<pre><code>/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';
</code></pre>
<p>This works, but as the default value, it is heavily targeted by <a href="http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/" title="Protect WordPress Against Malicious URL Requests">malicious scripts</a> and <a href="http://perishablepress.com/press/2010/07/14/blackhole-bad-bots/" title="Protect Your Site with a Blackhole for Bad Bots">bad bots</a>. Changing it to something <em>unique</em> essentially <em>immunizes</em> it against automated attacks on anything prefixed with <code>wp_</code>. The more <em>random and unique</em> the better, like a password: &ldquo;<code>h7G3vcDEo3jDf_</code>&rdquo; would be a good example. Note that ending the string with an underscore or some other easily recognizable character is a good way to keep things readable and easy to use.</p>
<h4>4) WordPress Localized Language</h4>
<p>By default WordPress uses the English language, but you can use any available language by following <a href="http://codex.wordpress.org/Installing_WordPress_in_Your_Language" title="Installing WordPress in Your Language">these steps</a>. As a part of that process, you&rsquo;ll specify your language in this part of the <code>wp-config.php</code> file:</p>
<pre><code>/**
 * WordPress Localized Language, defaults to English.
 *
 * Change this to localize WordPress.  A corresponding MO file for the chosen
 * language must be installed to wp-content/languages. For example, install
 * de.mo to wp-content/languages and set WPLANG to 'de' to enable German
 * language support.
 */
define ('WPLANG', '');</code></pre>
<p>It&rsquo;s pretty straightforward: if nothing is specified (as is seen here), English is used; otherwise, you include the <code>.mo</code> language file you are using for the translation.</p>
<h3 id="pimpin">Additional Tips and Tricks</h3>
<p>Now that you&rsquo;ve got the database connection, security keys, table prefix, and language definition dialed in you&rsquo;re ready to rock. Most WordPress sites are in great shape at this point, but there is <em>much</em> more that we can do with <code>wp-config.php</code> to maximize performance and make our lives easier.</p>
<h4>Pimping Post Revisions</h4>
<p>Recent versions of WordPress provides a post-revisioning system that enables users to save different versions of their blog posts and even revert to previously saved versions if necessary. Regardless of how much you do or do not despise this amazingly awesome feature, here are a couple of configurational definitions that may prove useful for you:</p>
<pre><code>// Limit the number of saved revisions
define('WP_POST_REVISIONS', 3); // any integer, but don't go crazy

// Disable the post-revisioning feature
define('WP_POST_REVISIONS', false); // kill the bloat</code></pre>
<h4>Specify the Autosave Interval</h4>
<p>In a similar vein as the post-revisioning feature is WordPress’ actually useful Autosave functionality. By default, WordPress saves your work every 60 seconds, but you can totally modify this setting to whatever you want. Don’t get too crazy though, unless you want to stress-out your server&nbsp;;)</p>
<pre><code>define('AUTOSAVE_INTERVAL', 160); // in seconds, don't go nuts</code></pre>
<h4>Automated Trash</h4>
<p>Since WordPress 2.9, we&rsquo;ve had the &ldquo;Trash&rdquo; feature to help prevent accidents. So now instead of deleting stuff like posts and comments, you send them to the Trash. By default WordPress deletes the Trash every 30 days, but you can set it to whatever you want by adding a line like this to <code>wp-config.php</code>:</p>
<pre><code>define('EMPTY_TRASH_DAYS', 7); // empty weekly</code></pre>
<p>To ride bareback without the safety net, you can disable the Trash feature by specifying a zero value:</p>
<pre><code>define('EMPTY_TRASH_DAYS', 0); // disable trash</code></pre>
<p>By disabling Trash, you&rsquo;ll be deleting stuff permanently the first time, just like way back in the day.</p>
<h4>Automatic Database Repair</h4>
<p>WordPress 2.9 also gave us automatic database repair, which enables you to repair and optimize your database even when not logged in. This functionality should be used on an <em>as-needed</em> basis by first adding the following snippet to <code>wp-config.php</code>:</p>
<pre><code>define('WP_ALLOW_REPAIR', true);</code></pre>
<p>With that in place, visit the following <abbr title="Uniform Resource Locator">URL</abbr> to open the &ldquo;Database Repair&rdquo; page:</p>
<p><code>http://example.com/wp-admin/maint/repair.php</code></p>
<p>There you&rsquo;ll be able to optimize and repair your database without needing to log in to WordPress. Important: While you have  <code>WP_ALLOW_REPAIR</code> set in <code>wp-config.php</code>, the Database Repair page is openly accessible by anyone who finds it. So definitely remove the line to disable the auto-repair functionality after you are done using it.</p>
<h4>Block External Requests</h4>
<p>If you need to prevent WordPress from making external requests, add this snippet to <code>wp-config.php</code>:</p>
<pre><code>define('WP_HTTP_BLOCK_EXTERNAL', true);</code></pre>
<p>This will prevent things from happening that normally happen, like updates, dashboard feeds, and data reporting. Fortunately, it&rsquo;s easy to whitelist (<em>allow</em> access) anything that is needed. Here is an example where we grant access to pingomatic.com:</p>
<pre><code>define('WP_ACCESSIBLE_HOSTS', 'rpc.pingomatic.com');</code></pre>
<h4>Blog Address and Site Address</h4>
<p>By default, these two configurational definitions are not included in the <code>wp-config.php</code> file, but they may be added to improve performance. These two settings were introduced in WordPress version 2.2 and override the database value without actually changing them. Example:</p>
<pre><code>define('WP_HOME', 'http://digwp.com'); // no trailing slash
define('WP_SITEURL', 'http://digwp.com');  // no trailing slash</code></pre>
<p>These settings should match those specified in your WordPress Admin. Once you set them in <code>wp-config.php</code>, they will be &ldquo;grayed-out&rdquo; when displayed in the Admin.</p>
<h4>Debugging WordPress</h4>
<p>Since WordPress version 2.3.1, users have been able to display certain errors and warnings to help with the debugging of their site. As of WordPress version 2.5, enabling error reporting raises the reporting level to <code>E_ALL</code> and activates warnings for deprecated functions. By default (i.e., if no definition is specified in the <code>wp-config.php</code> file), error reporting is disabled.</p>
<pre><code>define('WP_DEBUG', true); // debugging mode: 'true' = enable; 'false' = disable</code></pre>
<p>Adding that snippet to <code>wp-config.php</code> tells WordPress to display warnings and error messages with your web pages. This functionality is <em>extremely useful</em> but infrequently used by plugin and theme developers. If you&rsquo;ve never enabled debugging, you&rsquo;re in for a surprise &ndash; lots of errors even with some of the most popular plugins.</p>
<h4>Error Log Configuration</h4>
<p>Here is an easy way to enable basic error logging for your WordPress-powered site. Create a file called <code>php_error.log</code>, make it server-writable, and place it in the directory of your choice. Then edit the path in the third line of the following code and place into your <code>wp-config.php</code>:</p>
<pre><code>@ini_set('log_errors','On');
@ini_set('display_errors','Off');
@ini_set('error_log','/home/path/domain/logs/php_error.log');</code></pre>
<p>Error logs are powerful tools for keeping an eye on things and expediently resolving issues. It&rsquo;s awesome that WordPress makes this so easy. We cover this in greater depth along with a couple of other methods in <a href="http://digwp.com/2009/07/monitor-php-errors-wordpress/" title="3 Ways to Monitor PHP Errors">this post</a>.</p>
<h4>Increase PHP Memory</h4>
<p>If you are receiving error messages telling you that your &ldquo;Allowed memory size of xxx bytes exhausted,&rdquo; this setting may help resolve the issue. As of WordPress version 2.5, the <code>WP_MEMORY_LIMIT</code> definition enables you to specify the maximum amount of memory that may be used by PHP. Here are some examples:</p>
<pre><code>define('WP_MEMORY_LIMIT', '64M');
define('WP_MEMORY_LIMIT', '96M');
define('WP_MEMORY_LIMIT', '128M');</code></pre>
<p>By default, WordPress will automatically attempt to increase PHP memory up to 32MB, so this setting is only needed for values higher than 32MB. Note that some web hosts disable your ability to increase PHP memory, so you may need to ask (or beg) for them to do it.</p>
<h3>More info, tips and tricks for wp-config</h3>
<p>For more information on the <code>wp-config.php</code> file, <a href="http://codex.wordpress.org/Editing_wp-config.php" title="Editing wp-config.php">check out the WordPress Codex</a>. We also have some <a href="http://digwp.com/2009/06/wordpress-configuration-tricks/" title="WordPress Configuration Tricks">awesome wp-config tricks</a> and <a href="http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/" title="Optimize WordPress Performance with the wp-config.php File">wp-config optimization tips</a> for your WordPress enjoyment :)</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/08/pimp-your-wp-config-php/">Permalink</a> | <a href="http://digwp.com/2010/08/pimp-your-wp-config-php/#comments">44 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/08/pimp-your-wp-config-php/&title=Pimp your wp-config.php">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/config/" rel="tag">config</a>, <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/performance/" rel="tag">performance</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/08/pimp-your-wp-config-php/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Mastering WordPress Post-Revisioning and Auto-Save Features</title>
		<link>http://digwp.com/2009/07/mastering-wordpress-post-revisioning-and-auto-save-features/</link>
		<comments>http://digwp.com/2009/07/mastering-wordpress-post-revisioning-and-auto-save-features/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 06:06:25 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[editing]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=344</guid>
		<description><![CDATA[Not everyone loves the post-revisioning feature of WordPress. In fact, some people can&#8217;t stand it. On the one hand, it&#8217;s nice to have a library of post-draft revisions to drudge through if you should ever make a mistake. On the other hand, multiple copies of every post is a great way to bloat your database [...]]]></description>
			<content:encoded><![CDATA[<p>Not everyone <em>loves</em> the post-revisioning feature of WordPress. In fact, some people can&rsquo;t stand it. On the one hand, it&rsquo;s nice to have a library of post-draft revisions to drudge through if you should ever make a mistake. On the other hand, multiple copies of <em>every</em> post is a great way to bloat your database with otherwise useless information. </p>
<p>Then, to complicate matters, WordPress&rsquo; auto-save functionality seems to have a mind of its own, at times interfering in the revisioning process even when post-revisioning has been disabled. Taken together, these post-revisioning and auto-save features have been known to confuse and frustrate WordPress users.</p>
<p>In this article, I explain how to take full control of WordPress&rsquo; version-revision and auto-save functionality. We&rsquo;ll explore how these features work, why they don&rsquo;t, when they clash, and how to stop the madness once and for all. </p>
<p><span id="more-344"></span></p>
<h3>WordPress AutoSave Feature</h3>
<p>WordPress implemented the AutoSave feature in version 2.1. Its function is to periodically (every 60 seconds by default) and automatically save your post while you work. Aside from the <a href="http://perishablepress.com/press/2008/03/17/wordpress-tip-careful-with-that-autosave-eugene/" title="WordPress Tip: Careful with that Autosave, Eugene">occasional hiccup</a>, AutoSave works great and is a genuine benefit to most WordPress users. Unlike version revisioning, AutoSave does not create a new database entry for every save. Instead, a single database entry is created for each post and is updated with each AutoSave cycle. AutoSave isn&rsquo;t perfect, however, and many folks find the time interval between saves either too brief or too long. Fortunately, WordPress makes it easy to modify the autosave interval with a simple <a href="http://digwp.com/2009/06/wordpress-configuration-tricks/" title="WordPress Configuration Tricks">configuration trick</a>:</p>
<p><code>define('AUTOSAVE_INTERVAL', 300); // in seconds</code></p>
<p>Simply specify your desired autosave interval (in seconds) and add to your <code>wp-config.php</code> file to enjoy immediate results.</p>
<p>If you are one of the rare individuals who prefers to write <em>without</em> the autosave feature, here is an easy way to turn it off:</p>
<pre><code>function disable_autosave() {
	wp_deregister_script('autosave');
}
add_action('wp_print_scripts','disable_autosave');</code></pre>
<p>Just add that slice of code to your theme&rsquo;s <code>functions.php</code> and say goodbye to Autosave!</p>
<h3>WordPress Post Revisioning Feature</h3>
<p>WordPress implemented Post Revisioning (aka Version Revisioning) in version 2.6. Its function is to record changes made to your documents by storing unique revisions in the database. While this feature may benefit a few users, it is widely understood that most WordPress users have no need for this level of functionality. In my humble opinion, the revisioning &ldquo;feature&rdquo; is overkill and completely excessive. It should have been left out of the core (i.e., released as a plugin) or there should be an Admin option to completely disable it. Post revisioning creates extraneous database content and, in my experience, functions inconsistently and unpredictably. Fortunately, there is an easy way to disable it by adding the following line to your <code>wp-config.php</code> file:</p>
<p><code>define('WP_POST_REVISIONS',false);</code></p>
<p>Or, if you prefer to keep the versioning functionality but limit the number of allowed revisions, add the following line to your <code>wp-config.php</code> file:</p>
<p><code>define('WP_POST_REVISIONS',3);</code></p>
<p>There is even a way to clean up your database by deleting all post-revision data. <a href="http://andreineculau.com/blog/2008/07/delete-wordpress-26-revisions/" title="Delete WordPress 2.6 Revisions">Andrei Neculau</a> shows us how via this handy little <acronym title="Structured Query Language">SQL</acronym> command:</p>
<pre><code>DELETE a,b,c FROM wp_posts a 
LEFT JOIN wp_term_relationships b 
ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c 
ON (a.ID = c.post_id) WHERE a.post_type = 'revision';</code></pre>
<p>That magical query will nuke all post-revisions and associated meta-data from the database.</p>
<h3>AutoSave + Versioning = Chaos?</h3>
<p>So far, everything presented in this article is fairly straightforward. At this point, I would like to discuss a persistent post-reversioning issue that continues to rear its ugly head even when post revisioning is disabled via the previously prescribed method. Apparently, there is no way to disable WordPress&rsquo; post-revisioning functionality. It continues to work behind the scenes even after setting the <code>WP_POST_REVISIONS</code> variable to <code>false</code> in the configuration file.</p>
<p>Why do I say this? Because I have experienced the following series of events with several different WordPress installations:</p>
<ol>
<li>Install WordPress</li>
<li>Disable Post-Revisioning</li>
<li>Write a post, save it, edit it</li>
<li>Notice a message that says something like this:</li>
</ol>
<blockquote><p><em>There is an autosave of this page that is more recent than the version below.</em></p></blockquote>
<p>I can see how the timestamp on an autosave may conflict with the actual post during post editing, but when the database is examined after receiving this message, multiple post revisions are usually found. Apparently, WordPress is still saving post revisions behind the scenes even when revisioning has been disabled. With revisioning disabled, an option to compare reversions will never be shown explicitly, but the comparative functionality continues to operate. Further, there is no way to examine a list of the unintended post revisions. They exist in the database, but not in the Admin area. Thus, to see and compare these revisions, you need to do it manually. Here is a recipe for doing so:</p>
<ul>
<li>Log into a database interface like phpMyAdmin</li>
<li>Run the following <acronym title="Structured Query Language">SQL</acronym> query:</li>
</ul>
<pre><code>SELECT * FROM `wp_posts` WHERE post_type = "revision"</code></pre>
<p>If this query returns results, WordPress has been saving revisions without your consent. To delete these revisions and all of their post data, see the method prescribed above. To see and compare different revisions in the WordPress Admin before taking action, continue with the following steps (screenshot provided for clarity):</p>
<p><img src="http://digwp.com/wp-content/blog-images/wordpress-revisions.gif" alt="[ Screenshot: Post ID columns as seen via phpMyAdmin ]" /><br /><small>Post ID columns as seen via phpMyAdmin</small></p>
<ul>
<li>Determine the <strong>original post ID</strong> for each set of revisions</li>
<li>Determine the <strong>revision post ID</strong> of each individual revision</li>
<li>For each set of revisions that you would like to compare, enter the following URL in your browser&rsquo;s address bar:</li>
</ul>
<pre><code>http://domain.tld/wp-admin/revision.php?action=diff&amp;right=X&amp;left=Y</code></pre>
<p>Edit the domain to match your own, and then replace &ldquo;<code>X</code>&rdquo; and &ldquo;<code>Y</code>&rdquo; with the revision post IDs of any two revisions you would like to compare (order does not seem to matter).</p>
<p>Repeat these steps to compare as many revisions as is necessary. To view an individual revision, edit the following code with the ID of the desired revision and enter it into your browser&rsquo;s address bar:</p>
<pre><code>http://domain.tld/wp-admin/revision.php?revision=N</code></pre>
<p>Once you have evaluated your autosaved revisions, they may be safely deleted, either all at once via the <acronym title="Structured Query Language">SQL</acronym> query provided above, or else individually by simply clicking the delete button (the red &ldquo;x&rdquo; in phpMyAdmin) next to each revision in the <code>wp_posts</code> table.</p>
<h3>Share your experience</h3>
<p>I&rsquo;m curious to know what other WordPress users think of the post-revisioning and auto-save features. Do you use them, and if so, how are they beneficial? Have you ever experienced unexpected or unexplainable behavior while writing a post while using post-revisioning functionality? It would also be interesting to find out how many people think the post-revisioning feature should have been included in the WordPress core.</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/07/mastering-wordpress-post-revisioning-and-auto-save-features/">Permalink</a> | <a href="http://digwp.com/2009/07/mastering-wordpress-post-revisioning-and-auto-save-features/#comments">14 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/07/mastering-wordpress-post-revisioning-and-auto-save-features/&title=Mastering WordPress Post-Revisioning and Auto-Save Features">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/editing/" rel="tag">editing</a>, <a href="http://digwp.com/tag/optimization/" rel="tag">optimization</a>, <a href="http://digwp.com/tag/performance/" rel="tag">performance</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/07/mastering-wordpress-post-revisioning-and-auto-save-features/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Optimize WordPress Performance with the wp-config.phpÂ File</title>
		<link>http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/</link>
		<comments>http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 07:16:58 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=245</guid>
		<description><![CDATA[As you may recall, there are a ton of configuration tricks available for the WordPress wp-config.php file. So many in fact, that I think many people may have missed some of the choice definitions aimed at optimizing WordPress performance. In this post, we&#8217;ll explore the best ways to improve your site&#8217;s performance with WordPress&#8217; wp-config.php [...]]]></description>
			<content:encoded><![CDATA[<p>As you may recall, there are a <a href="http://digwp.com/2009/06/wordpress-configuration-tricks/" title="WordPress Configuration Tricks">ton of configuration tricks</a> available for the WordPress <code>wp-config.php</code> file. So many in fact, that I think many people may have missed some of the choice definitions aimed at <strong>optimizing WordPress performance</strong>. In this post, we&rsquo;ll explore the best ways to improve your site&rsquo;s performance with WordPress&rsquo; <code>wp-config.php</code> file.</p>
<p><span id="more-245"></span></p>
<h3>Hardcode your Blog Address and Site Address</h3>
<p>Every time your site references your Blog Address or Site Address via WordPress template tags, a query must be made to your database. <strong>Update:</strong> apparently, the database is only queried for these values for each page load, not for every use of a template tag (thanks to Nathan Rice for the <a href="#comment-577" title="Read original comment">clarification</a>). This happens more often than you may realize, as there are a number of template tags and parameters that access this information:</p>
<ul>
<li><code>&lt;?php get_bloginfo('url'); ?&gt;</code> &#8212; Returns the <acronym title="Uniform Resource Locator">URL</acronym> of your site</li>
<li><code>&lt;?php get_bloginfo('wpurl'); ?&gt;</code> &#8212; Returns the <acronym title="Uniform Resource Locator">URL</acronym> of your blog</li>
<li><code>&lt;?php bloginfo('url'); ?&gt;</code> &#8212; Displays the <acronym title="Uniform Resource Locator">URL</acronym> of your site</li>
<li><code>&lt;?php bloginfo('home'); ?&gt;</code> &#8212; Displays the <acronym title="Uniform Resource Locator">URL</acronym> of your blog</li>
</ul>
<p>These tags display or return the associated information about your blog based on the information supplied in the General Settings panel in the WordPress Admin (Settings &gt; General). Once entered in the Admin, your Blog Address and Site Address information is stored in the WordPress database and must be queried for every instance of each of the above template tags (and probably others as well). This may not seem like much, but the net effect on performance can be significant.</p>
<p>Fortunately, WordPress provides a way to eliminate these unnecessary database queries by enabling us to hardcode the values directly into the <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> construct. By defining the <code>WP_HOME</code> and <code>WP_SITEURL</code> constants in your site&rsquo;s <code>wp-config.php</code> file, you can boost performance by reducing the number of queries made to your WordPress database. The following two definitions were introduced in WordPress version 2.2 and override the database values without actually changing them (note that you should not include a trailing slash at the end of either URL):</p>
<pre><code>define('WP_HOME', 'http://digwp.com'); // blog url
define('WP_SITEURL', 'http://digwp.com'); // site url</code></pre>
<p>Note that these settings should match those specified in your WordPress Admin. Also, once these values are defined in the configuration file, they will be &ldquo;greyed out&rdquo; in the Admin General Settings panel. Removal of the definitions will restore your ability to edit them via the Admin panel.</p>
<h3>Hardcode your Template Path and Stylesheet Path</h3>
<p>In a similar vein, we may further optimize performance by eliminating database queries for your site&rsquo;s Template Path and Stylesheet Path. These two variables are defined based on the intrinsic structure of the WordPress installation as well as the name of the currently active theme. Many WordPress themes employ the following template tags to determine the values of these two variables:</p>
<ul>
<li><code>&lt;?php get_bloginfo('stylesheet_directory'); ?&gt;</code> &#8212; Returns the <acronym title="Uniform Resource Locator">URL</acronym> of the stylesheet directory of the active theme</li>
<li><code>&lt;?php get_bloginfo('template_directory'); ?&gt;</code> &#8212; Returns the <acronym title="Uniform Resource Locator">URL</acronym> of the active theme&rsquo;s directory</li>
<li><code>&lt;?php bloginfo('stylesheet_directory'); ?&gt;</code> &#8212; Displays the <acronym title="Uniform Resource Locator">URL</acronym> of the stylesheet directory of the active theme</li>
<li><code>&lt;?php bloginfo('template_directory'); ?&gt;</code> &#8212; Displays the <acronym title="Uniform Resource Locator">URL</acronym> of the active theme&rsquo;s directory</li>
<li><code>&lt;?php get_stylesheet_directory(); ?&gt;</code> &#8212; Returns the stylesheet directory path for the current theme</li>
<li><code>&lt;?php get_template_directory() ?&gt;</code> &#8212; Returns the absolute path for the template directory of the current theme</li>
</ul>
<p>These tags function by assuming a standard directory structure for the WordPress installation (i.e., <code>/wp-content/themes/</code>) and then query the database for the value of the current active theme. </p>
<p>As with the predefined constants for Blog Address and Site Address (see previous section), you can also boost performance by eliminating database queries for your site&rsquo;s Template Path and Stylesheet Path. The following two definitions were introduced in WordPress version 2.2 and override the database values without actually changing them (note that you should not include a trailing slash at the end of either URL):</p>
<pre><code>define('TEMPLATEPATH', '/absolute/path/to/wp-content/themes/H5');
define('STYLESHEETPATH', '/absolute/path/to/wp-content/themes/H5');</code></pre>
<p>Note that hardcoding these values will disable your ability to switch themes successfully via the WordPress Admin (Appearance &gt; Themes). To do so, simply remove these two definitions, make the switch, and then edit them with the name of the new theme. </p>
<h3>Define your four Salt Values</h3>
<p>In my article, <a href="http://digwp.com/2009/06/wordpress-configuration-tricks/" title="WordPress Configuration Tricks">WordPress Configuration Tricks</a>, I discuss the four security keys that were introduced in WordPress version 2.7. These four keys work silently in the background and protect your site by enhancing cookie encryption. The values for these four keys should be as random and complicated as possible, and are easily and automatically generated at the <a href="http://api.wordpress.org/secret-key/1.1/" title="WordPress.org secret-key service">WordPress.org secret-key service</a>. These predefined keys are placed into your <code>wp-config.php</code> file and may be changed at any time (thereby nullifying your visitors&rsquo; old cookies):</p>
<pre><code>define('AUTH_KEY',        '#Sl2}YZFq~~.g=3HT 4+_;l7;#N~e]5._J!u*Y=qvFNhi(E{B9p% }+&gt;rnh8t~Bl');
define('SECURE_AUTH_KEY', 'G/Huwa6Ri6zkkEqz (~*J$O8M72pe&gt;+YrdW|+N_s2*qD%rM,;jF1%c3M!vQ&gt;2`{i');
define('LOGGED_IN_KEY',   'r/N1ssKv7Vxnd2Oj!O3oP+/-[}eSboXBt=(%T`.N7aA%}I%|-):[&amp;@D`r&gt;:Rk_R#');
define('NONCE_KEY',       '~1 -@]b]LMEPzbv#)d1Cz(.7_KHVyP@UG[J&amp;31_r5aC0WAWxpvGF;a^-@YnWt7x@');</code></pre>
<p>Used in conjunction with these four definitions are four corresponding &ldquo;salt&rdquo; values. Ideally, these four salt values are as complex and random as the their four encryption-key counterparts. If the salt is not defined elsewhere, WordPress will query the database to generate their values. These generated values are then stored in the WordPress database and must be queried for every use of the encryption keys. Obviously, eliminating these database queries will serve us well in boosting the performance of our WordPress-powered sites. Thanks to the <a href="#comment-400" title="Read original comment">heads up</a> from <a href="http://blog.avirtualhome.com/">Peter van der Does</a>, we now know that these four salt constants also may be defined in the <code>wp-config.php</code> file. Here is an example:</p>
<pre><code>define('AUTH_SALT',        '&gt;#m3m?hTy0Lg&lt;oB=ko7Z`8Z&amp;(1gs=FhPug^NniIVpkdo+&amp; c+$]B),H9*7ZMfDGT');
define('SECURE_AUTH_SALT', 'f~N&gt;{|CYc5uuED{^f7)+hEbnh(E,&lt;* 3:7DFcc$)SJS|=Tw^};@ti$714f:-zxjC');
define('LOGGED_IN_SALT',   ':-HRrr}&lt;zW=QwH8F!aUa#|q-xe(pjFK$wt!8G69ttHp4hNfxs[+u-mdxF=3ll{5e');
define('NONCE_SALT',       'F)H4}[Xh?F={lMW8F|gVH~iI!8$0*?X!7IZfr`0Q2-P1EL?:E[0hE&gt;&gt;(+!tTZ/H$');</code></pre>
<p>Exactly how do these salt values interact with their corresponding security keys? As Peter explains in his comment:</p>
<blockquote><p><em>The <code>NONCE_KEY</code>, for example is used by the functions <code>wp_nonce_field</code> and <code>check_admin_referer</code>. The strings passed on by these functions are used to create a unique hash. The function used is to create this hash is <code>hash_hmac</code> and the key for this function is the <code>NONCE_KEY</code> + <code>NONCE_SALT</code>.</em></p></blockquote>
<p>The bottom line here is that, by including these four salt definitions alongside your four security keys, you can improve site performance by eliminating extraneous database queries. You can even use the same <a href="http://api.wordpress.org/secret-key/1.1/" title="WordPress.org secret-key service">secret-key service</a> to generate the random data (just remember to only copy the salt values and not the entire block of code). And, as with the security-key definitions, the salt values may be changed at any time.</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/">Permalink</a> | <a href="http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/#comments">31 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/&title=Optimize WordPress Performance with the wp-config.phpÂ File">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/config/" rel="tag">config</a>, <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/optimization/" rel="tag">optimization</a>, <a href="http://digwp.com/tag/performance/" rel="tag">performance</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
	</channel>
</rss>

