<?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>Internet Business &#38; Marketing Strategy - Andy Beard &#187; htaccess</title>
	<atom:link href="http://andybeard.eu/tag/htaccess/feed" rel="self" type="application/rss+xml" />
	<link>http://andybeard.eu</link>
	<description>Internet Marketing, Lead Acquisition, Online Business Strategy and Social Media with Original Opinion and Loads of Attitude</description>
	<lastBuildDate>Sun, 12 Feb 2012 06:16:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>WordPress Hacked? Total Security Lockdown</title>
		<link>http://andybeard.eu/2517/wordpress-hacked.html</link>
		<comments>http://andybeard.eu/2517/wordpress-hacked.html#comments</comments>
		<pubDate>Tue, 08 Dec 2009 10:34:11 +0000</pubDate>
		<dc:creator>Andy Beard</dc:creator>
				<category><![CDATA[blogging tips]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[301 redirect]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[http user agent]]></category>
		<category><![CDATA[WordPress Hacked]]></category>
		<category><![CDATA[WordPress Security]]></category>

		<guid isPermaLink="false">http://andybeard.eu/?p=2517</guid>
		<description><![CDATA[
<p>It is no huge secret that I have had this WordPress blog hacked twice this year but some consolation is that <a href="http://themeshaper.com/dont-get-hacked-wordpress-security-tips/">I am not alone</a>.</p>
<h2>Helpful resources</h2>
<p>Alex recently launched a DVD course on <a href="http://lockyourblog.com/">WordPress security</a> that is available for FREE + shipping<br />
Stop &#8211; I know what you are thinking &#8211; FREE + Shipping these days normally comes with lots of strings attached, forced continuity often hidden etc. Whilst Alex does cross-sell a few related products, the main offer is genuinely free.</p>
<p><a href="http://andybeard.eu/2517/wordpress-hacked.html" class="more-link">Read more on WordPress Hacked? Total Security Lockdown&#8230;</a></p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fandybeard.eu%252F2517%252Fwordpress-hacked.html%22%2C%20%22style%22%3A%20%22small%22%2C%20%22title%22%3A%20%22WordPress%20Hacked%3F%20Total%20Security%20Lockdown%22%20%7D);"></div>


	Tags: <a href="http://andybeard.eu/tag/301-redirect" title="301 redirect" rel="tag">301 redirect</a>, <a href="http://andybeard.eu/tag/htaccess" title="htaccess" rel="tag">htaccess</a>, <a href="http://andybeard.eu/tag/http-user-agent" title="http user agent" rel="tag">http user agent</a>, <a href="http://andybeard.eu/tag/wordpress" title="wordpress" rel="tag">wordpress</a>, <a href="http://andybeard.eu/tag/wordpress-hacked" title="WordPress Hacked" rel="tag">WordPress Hacked</a>, <a href="http://andybeard.eu/tag/wordpress-security" title="WordPress Security" rel="tag">WordPress Security</a><br />
]]></description>
			<content:encoded><![CDATA[
<p>It is no huge secret that I have had this WordPress blog hacked twice this year but some consolation is that <a href="http://themeshaper.com/dont-get-hacked-wordpress-security-tips/">I am not alone</a>.</p>
<h2>Helpful resources</h2>
<p>Alex recently launched a DVD course on <a href="http://lockyourblog.com/">WordPress security</a> that is available for FREE + shipping<br />
Stop &#8211; I know what you are thinking &#8211; FREE + Shipping these days normally comes with lots of strings attached, forced continuity often hidden etc. Whilst Alex does cross-sell a few related products, the main offer is genuinely free.</p>
<p>Michael VanDeMar has a useful plugin to <a href="http://www.bad-neighborhood.com/login-lockdown.html">lock down your login</a> process</p>
<p>SEO Egg Head offers a <a href="http://www.seoegghead.com/software/wordpress-firewall.seo">WordPress firewall</a></p>
<p>Donna has a useful script for <a href="http://www.webchicklet.com/tools/monitorhackdfiles-tool-helps-fight-site-hackers/">monitoring your files</a></p>
<p>Of course you should also keep backups which you have total control over &#8211; this includes both database and files and you shouldn&#8217;t rely on claims that your webhost has a backup. With a VPS I find being able to &#8220;roll back&#8221; to a previous version useful, but backup with shared hosting plans supposedly made by admins isn&#8217;t a solution when you need to fix things in minutes.</p>
<p>Keep WordPress up to date, plugins up to date etc</p>
<p>Part of security is controlling what bots can crawl and index on your site, so some pamphlets would be useful as well</p>
<p><a href="http://sebastians-pamphlets.com/getting-urls-out-of-google-the-good-popular-definitive-way/">Getting URLs outta Google &#8211; the good, the popular, and the definitive way</a><br />
<a href="http://sebastians-pamphlets.com/handling-googles-neat-x-robots-tag-sending-rep-header-tags-with-php/">Handling Google’s neat X-Robots-Tag &#8211; Sending REP header tags with PHP</a> </p>
<h2>Nasty Bots &#038; Users</h2>
<p>A lot of security relies on identifying nasty bots, detecting rogue activity such as failed logins or preventing access to all but approved users using an additional layer of password protection, or only allowing access to a server from a specific IP or range of IP addresses.</p>
<p>Also it is important to realise that different WordPress implementations require different levels of access control. With WordPress frequently being used for membership sites, you need to allow access to members. This reduces the number of security options available.</p>
<h2>SEO Benefits</h2>
<p>Lots of the pages you want to block from being crawled for security purposes also need to somehow be blocked or removed from indexation for SEO purposes, so tightening up security using the right methods will have natural SEO benefits.</p>
<p>Robots.txt isn&#8217;t the best option because you end up with lots of blocked pages appearing in search results and potentially indexed instead of pages you want in the index. As Sebastian explained, you have to let the bots in to crawl a URL before you can redirect them.<br />
Not all bots can be identified, and not all bots obey robots.txt, though you can trap the naughty ones. If you are serious about your bot control you might also consider <a href="http://searchbotbase.com/">Fantomasters Searchbot Database</a>.</p>
<h2>User Agent Access Control For Total Lockdown</h2>
<p>Lots of security and SEO methods rely on identifying various bots and kicking them somewhere else with 301 redirects, or denying them access to areas they are not wanted.</p>
<p>Far better would be to only allow access to one specific user agent, and globally kick out anything that doesn&#8217;t match &#8211; this is the user agent equivalent to restricting access to only a single IP address.</p>
<p>But how could this be achieved?</p>
<p>Many SEOs would already be familiar with <a href="https://addons.mozilla.org/en-US/firefox/addon/59">User Agent Switcher</a> for Firefox. This allows you to wander around the web pretending to be someone else, or something else such as Googlebot.</p>
<p>Unfortunately User Agent Switcher has a nasty problem &#8211; you often forget you have it switched to something different and then suddenly realise when a website starts misbehaving, refusing you entry, redirecting you to funny places etc.</p>
<p>If you created a custom user agent for security purposes, it wouldn&#8217;t be very secure  if there was a chance you could broadcast it to lots of other webmasters by mistake. It is bad enough that user agent is broadcast &#8220;in the clear&#8221; unless you use SSL connections.</p>
<p>Then I came across an article discussing how to <a href="http://mirzmaster.wordpress.com/2009/10/09/helpful-hints-apple-movie-trailers-download-using-firefox-greasemonkey-and-user-agent-hack/">fake your user agent specifically for itunes</a> but not other sites.</p>
<p>The <a href="https://addons.mozilla.org/en-US/firefox/addon/11327">Header Control</a> Firefox plugin allows you to set your User Agent specific to a domain.</p>
<p>This would allow you to set a specific unique or relatively obscure user agent, and for it to only be used when accessing your own websites.</p>
<p>Even more useful this can be set up in multiple locations, work with variable IPs etc.</p>
<h2>Experimental</h2>
<p>This is something I am still experimenting with &#8211; I haven&#8217;t decided whether it is best to use .htaccess, php or a combination of both, and I am convinced the best option is to 301 redirect everything rather than deny access.<br />
The best option might be to use a combination htaccess > php so you can do some enhanced logging.</p>
<p>The user agent doesn&#8217;t have to be unique, it could just be an obscure out of date version of Firefox or Chrome.</p>
<p>Example .htaccess to deny access</p>
<pre class="brush: plain; title: ; notranslate">
RewriteEngine on
#
RewriteCond %{HTTP_user_agent} !^RareUserAgent
RewriteRule .* - [F,L]
#
</pre>
<p>Example .htaccess to 301 redirect </p>
<pre class="brush: plain; title: ; notranslate">
RewriteEngine on
#
RewriteCond %{HTTP_user_agent} !^RareUserAgent
RewriteRule ^ http://WhereIWantPagerank.com/MyMoneyPage/ [R=301,L]
#
</pre>
<p>What I haven&#8217;t included are rewrite conditions based on specific paths as I haven&#8217;t worked out exactly what paths I need to block whilst using specific <a href="http://www.newmedias.co.uk/wordpress-membership/">WordPress Membership Plugins</a>.</p>
<p><strong>Warning 1 &#8211; always have backups</strong><br />
<strong>Warning 2 &#8211; you can majorly mess up access to your website with htaccess it you get it wrong and can&#8217;t restore a working version</strong></p>
<p>Disclaimer/License: <a href="http://www.gnu.org/copyleft/fdl.html">GNU FDL</a> &#8211; run with it, make it useful</p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fandybeard.eu%252F2517%252Fwordpress-hacked.html%22%2C%20%22style%22%3A%20%22small%22%2C%20%22title%22%3A%20%22WordPress%20Hacked%3F%20Total%20Security%20Lockdown%22%20%7D);"></div>


	Tags: <a href="http://andybeard.eu/tag/301-redirect" title="301 redirect" rel="tag">301 redirect</a>, <a href="http://andybeard.eu/tag/htaccess" title="htaccess" rel="tag">htaccess</a>, <a href="http://andybeard.eu/tag/http-user-agent" title="http user agent" rel="tag">http user agent</a>, <a href="http://andybeard.eu/tag/wordpress" title="wordpress" rel="tag">wordpress</a>, <a href="http://andybeard.eu/tag/wordpress-hacked" title="WordPress Hacked" rel="tag">WordPress Hacked</a>, <a href="http://andybeard.eu/tag/wordpress-security" title="WordPress Security" rel="tag">WordPress Security</a><br />
]]></content:encoded>
			<wfw:commentRss>http://andybeard.eu/2517/wordpress-hacked.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Optimizing HTML Links In The Aftermath Of A Blog Storm</title>
		<link>http://andybeard.eu/1118/optimizing-html-links.html</link>
		<comments>http://andybeard.eu/1118/optimizing-html-links.html#comments</comments>
		<pubDate>Mon, 26 Nov 2007 13:21:18 +0000</pubDate>
		<dc:creator>Andy Beard</dc:creator>
				<category><![CDATA[blogging tips]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[SEO Blog]]></category>
		<category><![CDATA[301 redirect]]></category>
		<category><![CDATA[google juice]]></category>
		<category><![CDATA[Google PageRank]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[Internal Linking]]></category>
		<category><![CDATA[link juice]]></category>
		<category><![CDATA[Linking Structure]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[WordPress SEO]]></category>

		<guid isPermaLink="false">http://andybeard.eu/2007/11/optimizing-html-links.html</guid>
		<description><![CDATA[Hopefully if you ever get caught up in the whirlwind of a blog storm, and receive 10s, maybe even hundreds of links to one of your articles, that the topic of both the page being linked to, and the pages being linked from are related to your online business, and the topic of your blog.

It is quite likely that you have been developing other articles on similar topics for months, receiving very little online attention, and even more worrying, if you create follow-on articles providing important updates, they are less likely to be seen.

The majority of traffic will by default enter your site (the landing page) on the page that received the most links, and this traffic might continue for days, weeks, months and even years.

<img src='http://cdn5.andybeard.name/wp-content/uploads/blogstorm1.png' alt='Incoming HTML Links To A Single Article' />]]></description>
			<content:encoded><![CDATA[
<p>Hopefully if you ever get caught up in the whirlwind of a blog storm, and receive 10s, maybe even hundreds of links to one of your articles, that the topic of both the page being linked to, and the pages being linked from are related to your online business, and the topic of your blog.</p>
<p>It is quite likely that you have been developing other articles on similar topics for months, receiving very little online attention, and even more worrying, if you create follow-on articles providing important updates, they are less likely to be seen.</p>
<p>The majority of traffic will by default enter your site (the landing page) on the page that received the most links, and this traffic might continue for days, weeks, months and even years.</p>
<p><img src='http://cdn5.andybeard.name/wp-content/uploads/blogstorm1.png' alt='Incoming HTML Links To A Single Article' /></p>
<p><b>Ways to highlight other important information:-</b></p>
<ul>
<li>
<h3>Create a new post to inform your subscribers</h3>
<p>This has a tendency of alienating at least some of your readers, especially those who were not totally convinced by your &#8220;blog storm&#8221; article. It is quite possible that further articles will be looked on as &#8220;milking it&#8221;, trying to take advantage of a situation.<br />
Whilst this might be partially true, the process of providing updated information when/if you are the centre of attention is vital. This is how CNN catapulted into the mainstream, being on the scene of major news stories and providing &#8220;up to the minute&#8221; news updates.</li>
<li>
<h3>Related posts</h3>
<p>Useful for the few people who go to the trouble of clicking them though if they are generated automatically, they can be a little hard to control.<br />
The problem is that very few people tend to use them, and they generally appear after someone has read the &#8220;blog storm&#8221; article. Initial reaction will be to the first article they read, and not to any updates, unless you can force them to read updates.</li>
<li>
<h3>Update the article with links to newer information</h3>
<p>This is quite a time intensive operation because over the period of a few days you might have to make multiple updates to multiple articles, and when the blogstorm has died down, you might need to optimize the links even further.</p>
<ul>
<li>If all you do is create updates to a single post, whilst new visitors receive a relatively clear picture, your subscribers might only read the original article.</li>
<li>It is much easier in the flow of content creation to refer back to previous articles than to update previous articles with links to newer information.</li>
<li>If updates are drawn out over weeks or months, it can get very messy</li>
</ul>
</li>
</ul>
<h3>The Simple Solution</h3>
<p>One simple solution is to think of any news item as a series of posts, and to use a plugin designed to help you create a series of articles around a particular theme.</p>
<p>The <a href="http://remstate.com/projects/in-series/">In Series Plugin</a></p>
<p>The plugin is quite well documented, and will allow you to modify the order in which posts in a series are presented, and you can style the content such that it stands out.</p>
<h3>The Advanced Solution</h3>
<p>The ideal situation in many cases is to create a specific landing page for a series of articles, that can then be optimized for specific terms, and used to channel both humans and search engines towards the most important articles you want them to see.</p>
<p><img src='http://cdn5.andybeard.name/wp-content/uploads/blogstorm2.png' alt='Redirect HTML links towards a specific landing page' /></p>
<p>This is actually fairly easy to achieve in a number of ways, and most of the skills are similar to the various ways you can perform siloing I described in my <a href="http://andybeard.eu/2007/06/wordpress-seo-masterclass-for-competitive-niches.html">WordPress SEO</a> Masterclass.</p>
<p><b>Here are the basic tasks that need to be undertaken:-</b></p>
<ul>
<li>
<h3>How to create an optimized landing page</h3>
<p>There are a number of ways to create an optimized landing page. The ideal method will really depend on your existing site structure and the ways you currently highlight content.<br />
An additional concern is certainly your technical ability. It is much easier to create a round-up post or a page with related links than to create landing pages using more automated methods and get the page looking right.</p>
<ul>
<li><strong>Using a dedicated category</strong> with optimized template such as category-6.php in WordPress</li>
<li><strong>Creating a dedicated page</strong> with manually selected links</li>
<li><strong>Using a siloing plugin</strong> which presents posts from a particular category on a single page</li>
<li><strong>Writing an update post</strong> with links to each of the previous articles</li>
</ul>
</li>
<li>
<h3>Planning Content</h3>
<p>Work out which articles to link to from a landing page, keyword strategy, and linking structure both to the existing content on the topic, and to other pages you want to get a lot of link juice and attention.</li>
<li>
<h3>Planning Redirects</h3>
<p>Not all of this can be automated unfortunately. If you have made specific references to any of the articles that you are about to create redirects for, you need to make a note of them, because these might need to be adjusted so that they contain updated URLs.<br />
It is hard to do this with incoming links from external sources, and not always desired, but I think that internally where you might often have referenced 4 different articles from within an update page, it is best that those links remain pointing to the specific articles referenced, thus will need to be hand edited.</p>
<p>Create a table of original URLs, and the updated URL which will soon house that article.
</li>
<li>
<h3>Create Updated .htaccess</h3>
<p>Create&#8230; don&#8217;t upload yet</p>
<p>Here is an example .htaccess entry</p>
<pre class="brush: plain; title: ; notranslate">
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
redirect 301 /2007/01/day-job-killer-review.html http://andybeard.eu/2007/02/day-job-killer-review.html
&lt;/IfModule&gt;
</pre>
<p>In that particular example I was quite lazy and brought a review quickly to my front page by changing the publish date, but I also added a redirect because Google had indexed the old URL.</p>
<p>I would suggest that these changes should be made right at the end of your .htaccess file.</p>
<p>It is possible to manage 301 redirects with plugins, and WordPress 2.3+ is also meant to handle some things automatically, but I haven&#8217;t experimented with that yet and I don&#8217;t like being locked into using particular plugins for my site to function.
</li>
<li>
<h3>Create Landing Page</h3>
<p>Depending on the method you will be using this may or may not include updated URLs automatically. If you are crafting the links by hand, you may need to refer to your previously prepared table of changes.<br />
Until the redirects take place, the new landing page will get very little attention from Search Engines or visitors, and whilst it is not ideal to have currently broken links on a page, it is probably better to have a few links that are broken than have lots of visitors get redirected to a page that doesn&#8217;t exist.</li>
<li>
<h3>Upload .htaccess or Modify Existing URLs</h3>
<p>This stage speed is of the essence, as it is a bit like a chicken and the egg scenario. If you are working with a large site you might need to work out some way to automate this process.</p>
<p>If you upload the .htaccess first, then visitors will arrive at your landing page, and either click on links that return a 404 page not found error, or in the case of using categories or silo plugins, they will click on links that redirect to where they currently are on the landing page.<br />
However this is probably better than changing URLs before the .htaccess is in place.</p>
<p>Once you have uploaded the .htaccess, it is time to modify existing URLs to those you have planned to use.</p>
<p>I would suggest that &#8220;time is of the essence&#8221; at this stage, it is not something you can undertake at the end of a working day, though &#8220;more haste, less speed&#8221; should also be taken into consideration.</p>
<p><strong>Even with extensive planning, it is fairly easy to mess something up in your linking structure and 301 redirects.</strong>
</li>
</ul>
<p>This isn&#8217;t an article for SEO beginners, I leave those for the &#8220;experts&#8221; to write.</p>
<p>Your mileage may vary &#8211; I have written this article mainly as part of my own planning stage to make similar changes on this blog.<br />
I have a number of topics that could benefit from using this method, including WordPress SEO, PageRank, Dofollow, Technorati, and even my &#8220;about page&#8221; which could take advantage of many of the blogging memes.</p>
<p>How much benefit you might gain from this may be marginal from an SEO point of view, or could make a substantial difference.</p>
<p><strong>Fortunately the primary reason for doing this in many cases is to improve the browsing experience for users</strong>, so that they arrive at a landing page that provides them with a current overview of a topic, with possibly additional background articles that you feel are important.</p>
<p>There is a lot more to linking structure on a website or blog than just sticking nofollow on a few links to pages of less importance, or installing a wonder &#8220;do everything&#8221; SEO plugin.</p>
<p><b>Power Tip &#8211; once you get comfortable with this, you can actually plan your content with this strategy in mind, choosing your page titles and URLs carefully to maximise the benefit of redirects in the future.</b></p>
<p>In many ways this technique is the opposite to <a href="http://www.seo4fun.com/blog/2007/08/22/third-level-push-modified-siloing-for-deeper-index-penetration.html">3rd level push</a>, though the concepts are not mutually exclusive, as whilst you are diverting link juice from a 3rd level document to one on the second tier, that juice then flows evenly (if you want) to your 3rd level.</p>
<p><em>Optimize your site for users not search engines</em> ;) [cough]</p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fandybeard.eu%252F1118%252Foptimizing-html-links.html%22%2C%20%22style%22%3A%20%22small%22%2C%20%22title%22%3A%20%22Optimizing%20HTML%20Links%20In%20The%20Aftermath%20Of%20A%20Blog%20Storm%22%20%7D);"></div>


	Tags: <a href="http://andybeard.eu/tag/301-redirect" title="301 redirect" rel="tag">301 redirect</a>, <a href="http://andybeard.eu/tag/google-juice" title="google juice" rel="tag">google juice</a>, <a href="http://andybeard.eu/tag/google-pagerank" title="Google PageRank" rel="tag">Google PageRank</a>, <a href="http://andybeard.eu/tag/htaccess" title="htaccess" rel="tag">htaccess</a>, <a href="http://andybeard.eu/tag/internal-linking" title="Internal Linking" rel="tag">Internal Linking</a>, <a href="http://andybeard.eu/tag/link-juice" title="link juice" rel="tag">link juice</a>, <a href="http://andybeard.eu/tag/linking-structure" title="Linking Structure" rel="tag">Linking Structure</a>, <a href="http://andybeard.eu/tag/seo" title="SEO Blog" rel="tag">SEO Blog</a>, <a href="http://andybeard.eu/tag/wordpress" title="wordpress" rel="tag">wordpress</a>, <a href="http://andybeard.eu/tag/wordpress-seo" title="WordPress SEO" rel="tag">WordPress SEO</a><br />
]]></content:encoded>
			<wfw:commentRss>http://andybeard.eu/1118/optimizing-html-links.html/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>The Ultimate WordPress Htaccess File?</title>
		<link>http://andybeard.eu/612/the-ultimate-wordpress-htaccess-file.html</link>
		<comments>http://andybeard.eu/612/the-ultimate-wordpress-htaccess-file.html#comments</comments>
		<pubDate>Mon, 02 Apr 2007 16:11:32 +0000</pubDate>
		<dc:creator>Andy Beard</dc:creator>
				<category><![CDATA[blogging tips]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[mininet]]></category>
		<category><![CDATA[SEO Blog]]></category>
		<category><![CDATA[vre]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[Canonicalization]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[htaccess code]]></category>
		<category><![CDATA[Htaccess WordPress]]></category>
		<category><![CDATA[mod rewrite]]></category>
		<category><![CDATA[search engine optimization]]></category>
		<category><![CDATA[trailing slashes]]></category>

		<guid isPermaLink="false">http://andybeard.eu/2007/04/the-ultimate-wordpress-htaccess-file.html</guid>
		<description><![CDATA[<p>Canonicalization is a serious problem for webmasters, just read this <a href="http://www.mattcutts.com/blog/canonicalization-update/">latest entry by Matt Cutts</a> or  this <a href="http://www.johnon.com/267/trailing-slash-seo.html">great post from John Andrews</a>. However telling webmasters that they should fix these issues isn't enough, webmasters &#038; bloggers need solutions.</p>
<h3>In Search of the Ultimate Htaccess file</h3>
<p>A couple of months ago Alister Cameron posted a <a href="http://www.alistercameron.com/2007/01/12/two-wordpress-plugins-you-dont-need-and-shouldnt-use/">simple solution to .htaccess</a> such that you didn't need to use a plugin to convert URLs using www to URLs without.</p>
<p>At the time I suggested a couple of improvements, and also mentioned I would post about it here on my blog, hopefully to help</p>]]></description>
			<content:encoded><![CDATA[
<p>Canonicalization is a serious problem for webmasters, just read this <a href="http://www.mattcutts.com/blog/canonicalization-update/">latest entry by Matt Cutts</a> or  this <a href="http://www.johnon.com/267/trailing-slash-seo.html">great post from John Andrews</a>. However telling webmasters that they should fix these issues isn&#8217;t enough, <b>webmasters &#038; bloggers need solutions</b>.</p>
<h3>In Search of the Ultimate Htaccess file</h3>
<p>A couple of months ago Alister Cameron posted a <a href="http://www.alistercameron.com/2007/01/12/two-wordpress-plugins-you-dont-need-and-shouldnt-use/">simple solution to .htaccess</a> such that you didn&#8217;t need to use a plugin to convert URLs using www to URLs without.</p>
<p>At the time I suggested a couple of improvements, and also mentioned I would post about it here on my blog, hopefully to help develop what could be looked on as the &#8220;Ultimate&#8221; .htaccess file for WordPress, something you could just drop in your root folder and be done with it.<br />
For me the inclination was for multiple niche websites using WordPress as a CMS, so I really wanted to avoid anything that would make the content look dated.</p>
<div class="important" style="width:400px;">I am not an htaccess guru, and this is all cobbled together from code suggested by other people in various places<br />
<b>Before using any of this code, make a backup of your existing .htaccess, and be prepared to copy it back if testing proves something is broken.</b></div>
<p>Lets start off with the default .htaccess for WordPress once you turn on mod_rewrite for SEO friendly URLs</p>
<pre class="brush: plain; title: ; notranslate">
# BEGIN WordPress
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
&lt;/IfModule&gt;
# END WordPress
</pre>
<p>The first thing we want to do is get rid of the WWW if someone uses it. I know there are 2 schools of thought on whether URLs should have www by default or not, I prefer without and never type www unless I can&#8217;t access another site without it (broken htaccess).</p>
<p>Secondly we also want to get rid of trailing slash problems</p>
<p>The base rules that Alister first suggested were</p>
<pre class="brush: plain; title: ; notranslate">
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.alistercameron.com$ [NC]
RewriteRule ^(.*)$ http://www.alistercameron.com/$1 [R=301,L]

RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
&lt;/IfModule&gt;
</pre>
<p>However we want this to be the <b>Ultimate htaccess code</b>, thus we don&#8217;t want to have to enter the domain name. I am not sure whether this will work if you have multiple blogs in sub-folders.</p>
<p>In this code we are using HTTP_HOST rather than adding a URL manually to every .htaccess file you create. If you are setting up 50 blogs (niche marketers do things like this, and fill them with unique original content &#8211; not everyone creates splogs) then being able to use one default file is a major advantage.</p>
<pre class="brush: plain; title: ; notranslate">
# If subdomain www exists, remove it first
RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</pre>
<p>Can we improve on the trailing slashes code?</p>
<p>Possibly&#8230;</p>
<p>A while ago I was also reading a post over on Aaron Walls SEO Book blog. Within the comments were suggestions with improvements to the code Aaron suggested.<br />
Finding the exact reference is a problem as it wasn&#8217;t <a href="http://www.seobook.com/archives/001714.shtml">on this thread</a></p>
<p>Searching on a phrase in the code these days only brings up a reference on Alister&#8217;s blog where I mentioned it in the comments, so I have no idea who to attribute this htaccess code to.</p>
<pre class="brush: plain; title: ; notranslate">
# If requested resource does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# and does not end with a period followed by a filetype
RewriteCond %{REQUEST_URI} !..+$
# and does not end with a slash
RewriteCond %{REQUEST_URI} !/$
# then add a trailing slash and redirect
RewriteRule (.*) $1/ [R=301,L]
&lt;/IfModule&gt;
</pre>
<p><b>I am not a htaccess guru</b>, but this seems to take into account more potential situations such as files to download.</p>
<p>If you put all this code together you end up with something like this</p>
<pre class="brush: plain; title: ; notranslate">
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
# If subdomain www exists, remove it first
RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# If requested resource does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# and does not end with a period followed by a filetype
RewriteCond %{REQUEST_URI} !..+$
# and does not end with a slash
RewriteCond %{REQUEST_URI} !/$
# then add a trailing slash and redirect
RewriteRule (.*) $1/ [R=301,L]
&lt;/IfModule&gt;

# BEGIN WordPress
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
&lt;/IfModule&gt;

# END WordPress
</pre>
<p><strong>So can anyone offer any constructive improvements?</strong></p>
<p>If you offer improvements, please provide code samples and explain exactly why it is an improvement so people can learn from it (as I said I am a newbie at this)<br />
Code can be entered using code tags in square brackets.</p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fandybeard.eu%252F612%252Fthe-ultimate-wordpress-htaccess-file.html%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fi6jt8F%22%2C%20%22style%22%3A%20%22small%22%2C%20%22title%22%3A%20%22The%20Ultimate%20Wordpress%20Htaccess%20File%3F%22%20%7D);"></div>


	Tags: <a href="http://andybeard.eu/tag/blogging" title="blogging" rel="tag">blogging</a>, <a href="http://andybeard.eu/tag/blogging-tips" title="blogging tips" rel="tag">blogging tips</a>, <a href="http://andybeard.eu/tag/canonicalization" title="Canonicalization" rel="tag">Canonicalization</a>, <a href="http://andybeard.eu/tag/htaccess" title="htaccess" rel="tag">htaccess</a>, <a href="http://andybeard.eu/tag/htaccess-code" title="htaccess code" rel="tag">htaccess code</a>, <a href="http://andybeard.eu/tag/htaccess-wordpress" title="Htaccess WordPress" rel="tag">Htaccess WordPress</a>, <a href="http://andybeard.eu/tag/mod-rewrite" title="mod rewrite" rel="tag">mod rewrite</a>, <a href="http://andybeard.eu/tag/search-engine-optimization" title="search engine optimization" rel="tag">search engine optimization</a>, <a href="http://andybeard.eu/tag/seo" title="SEO Blog" rel="tag">SEO Blog</a>, <a href="http://andybeard.eu/tag/trailing-slashes" title="trailing slashes" rel="tag">trailing slashes</a><br />
]]></content:encoded>
			<wfw:commentRss>http://andybeard.eu/612/the-ultimate-wordpress-htaccess-file.html/feed</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Database Caching 33/60 queries in 0.011 seconds using disk: basic
Object Caching 1165/1228 objects using disk: basic
Content Delivery Network via cdn5.andybeard.name

Served from: andybeard.eu @ 2012-02-13 05:21:28 -->
