<?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>Richard Shepherd &#187; .htaccess</title>
	<atom:link href="http://www.richardshepherd.com/tag/htaccess/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richardshepherd.com</link>
	<description>Making the web. Better looking.</description>
	<lastBuildDate>Fri, 04 Jun 2010 18:03:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WordPress, IIS, Permalinks and index.php</title>
		<link>http://www.richardshepherd.com/wordpress-iis-permalinks-and-index-php/</link>
		<comments>http://www.richardshepherd.com/wordpress-iis-permalinks-and-index-php/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 18:12:35 +0000</pubDate>
		<dc:creator>richardshepherd</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[index.php]]></category>
		<category><![CDATA[isapi]]></category>
		<category><![CDATA[permalinks]]></category>

		<guid isPermaLink="false">http://www.richardshepherd.com/?p=592</guid>
		<description><![CDATA[Here&#8217;s the problem: You need to install WordPress on a Windows machine running IIS. I&#8217;d never normally do this, but sometimes you just don&#8217;t have a choice. There are plenty of links out there about how to do this, and the one I referred to most was How To Install WordPress on IIS 6.0. It [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the problem:</p>
<p>You need to install WordPress on a Windows machine running IIS. I&#8217;d never normally do this, but sometimes you just don&#8217;t have a choice.</p>
<p>There are plenty of links out there about how to do this, and the one I referred to most was <a href="http://www.iisadmin.co.uk/?p=6" target="_blank">How To Install WordPress on IIS 6.0</a>. It is, more or less, straightforward.</p>
<p>However, there&#8217;s an issue with IIS and permalinks.<span id="more-592"></span>The issue is that if you want to take advantage of the WordPress pretty permalinks, you have to suffer a folder in the path called &#8216;index.php&#8217;. So, instead of the rather lovely:</p>
<p><strong>http://www.yourblog.com/yourcategories/the-best-post-in-the-world/</strong></p>
<p>you have to grit your teeth and accept:</p>
<p><strong>http://www.yourblog.com/index.php/yourcategories/the-best-post-in-the-world/</strong></p>
<p>I don&#8217;t know why, I really don&#8217;t. I&#8217;m not that smart. But I did work out how to fix it. It&#8217;s easy enough, but you have to put a couple of rules in the ISAPI ReWrite Engine to deal with the quirks.</p>
<p>First we need to head into our WordPress admin tool, and go to Settings &gt; Permalinks. There, you&#8217;ll see the craft insertion of /index.php/ in the links. We need to create a custom permalink and <em>delete</em> the index.php bit. Just like this&#8230;</p>
<p><img class="alignnone size-full wp-image-598" title="WordPress Permalink Options" src="http://s85883.gridserver.com/wpblog/wp-content/uploads/2009/07/links1.jpg" alt="WordPress Permalink Options" width="504" height="373" /></p>
<p>Now save that off and head over to your .htaccess file &#8211; we need to weave some magic!</p>
<p>At the bottom of this post is the whole file, but the two lines I particularly want to point out are:</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!/</span>wp<span style="color: #339933;">-</span>admin<br />
RewriteRule <span style="color: #339933;">^/</span><span style="color: #009900;">&#40;</span>.<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>$ <span style="color: #339933;">/</span>index\.<span style="color: #202020;">php</span><span style="color: #339933;">/</span>$<span style="color: #0000dd;">1</span> <span style="color: #009900;">&#91;</span>NC<span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>The second line works the juju. It takes the URL from the browser, shoves an /index.php/ into it, and displays the contents. For more on how and why this works, check out <a href="http://www.workingwith.me.uk/articles/scripting/mod_rewrite" target="_blank">http://www.workingwith.me.uk/articles/scripting/mod_rewrite</a> for the basics.</p>
<p>Now the first line is <em>really</em> important, because it tells the server <strong>not</strong> to do this if we&#8217;re in the admin section. If we remove this line, there are all kinds of problems reaching /wp-admin/index.php. Trust me.</p>
<p>I have two other lines in the following code which get rid of index.php from URLS, which stops the google duplicate content issue. They&#8217;re always worth having.</p>
<p>Finally, make sure that wherever your site is hosted, that the correct permissions are set on the wp-admin and wp-content directories and their sub-directories. You must have read/write/modify permissions set for internal user accounts.</p>
<p>If you implement these small tweaks, then your WordPress IIS install should work like a charm.</p>
<p>Good luck!</p>
<p>Here&#8217;s the code:</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<span style="color: #339933;"># Kickstart the Rewrite Engine and set initial options</span><br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<br />
RewriteEngine On<br />
RewriteCompatibility2 On<br />
RepeatLimit <span style="color: #0000dd;">200</span><br />
RewriteBase<br />
<br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<span style="color: #339933;"># WORDPRESS, WINDOWS &amp; ISAPI DOCUMENTATION</span><br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<span style="color: #339933;"># These are the WordPress redirects we need in place for a Windows Server</span><br />
<span style="color: #339933;"># running PHP &amp; MySQL</span><br />
<span style="color: #339933;"># We had some issues configuring ISAPI with WordPress and so here are the</span><br />
<span style="color: #339933;"># solutions in case we need them again!!</span><br />
<br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<span style="color: #339933;"># PERMISSIONS SETTINGS</span><br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<span style="color: #339933;"># The following folders:</span><br />
<span style="color: #339933;"># wp-admin</span><br />
<span style="color: #339933;"># wp-content</span><br />
<span style="color: #339933;"># MUST HAVE read/write/modify permissions set for internal user accounts</span><br />
<br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<span style="color: #339933;"># ESSENTIAL WORDPRESS REWRITES</span><br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<br />
<span style="color: #339933;"># Redirects 'www.yourblogsite.com/index.php' to 'www.yourblogsite.com/'</span><br />
<br />
RewriteRule <span style="color: #339933;">^/</span>index\.<span style="color: #202020;">php</span>$ <span style="color: #339933;">/</span> <span style="color: #009900;">&#91;</span>NC<span style="color: #339933;">,</span>P<span style="color: #339933;">,</span>R<span style="color: #339933;">=</span><span style="color: #0000dd;">301</span><span style="color: #009900;">&#93;</span><br />
<br />
<span style="color: #339933;"># Rewrite 'www.yourblogsite.com/anything/' to 'www.yourblogsite.com/index.php/anything/'</span><br />
<span style="color: #339933;"># NB. The user does not see this rewrite.</span><br />
<span style="color: #339933;"># Must also go into WordPress &gt; Settings &gt; Permalinks and select 'custom'</span><br />
<span style="color: #339933;"># and then REMOVE 'index.php' from the custom URL it generates</span><br />
<br />
<span style="color: #339933;"># The first line is a condition so it doesn't apply the rule to the wp-admin part of the site</span><br />
<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!/</span>wp<span style="color: #339933;">-</span>admin<br />
RewriteRule <span style="color: #339933;">^/</span><span style="color: #009900;">&#40;</span>.<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>$ <span style="color: #339933;">/</span>index\.<span style="color: #202020;">php</span><span style="color: #339933;">/</span>$<span style="color: #0000dd;">1</span> <span style="color: #009900;">&#91;</span>NC<span style="color: #009900;">&#93;</span><br />
<br />
<span style="color: #339933;"># Finally, redirect 'www.yourblogsite.com/anything/anything/index.php'</span><br />
<span style="color: #339933;"># to 'www.yourblogsite.com/anything/anything/'</span><br />
<br />
RewriteRule <span style="color: #339933;">^/</span><span style="color: #009900;">&#40;</span>.<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>index\.<span style="color: #202020;">php</span>$ <span style="color: #339933;">/</span>$<span style="color: #0000dd;">1</span><span style="color: #339933;">/</span> <span style="color: #009900;">&#91;</span>NC<span style="color: #339933;">,</span>P<span style="color: #339933;">,</span>R<span style="color: #339933;">=</span><span style="color: #0000dd;">301</span><span style="color: #009900;">&#93;</span><br />
<br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span><br />
<span style="color: #339933;"># END OF ESSENTIAL REWRITES</span><br />
<span style="color: #339933;"># -------------------------------------------------------------------------</span></div></td></tr></tbody></table></div>
<p>Thanks for watching, kids&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardshepherd.com/wordpress-iis-permalinks-and-index-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>.htaccess and 302 redirect problems fixed</title>
		<link>http://www.richardshepherd.com/htaccess-and-302-redirect-problems-fixed/</link>
		<comments>http://www.richardshepherd.com/htaccess-and-302-redirect-problems-fixed/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 23:41:55 +0000</pubDate>
		<dc:creator>richardshepherd</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[301 redirect]]></category>
		<category><![CDATA[302]]></category>
		<category><![CDATA[302 redirect]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Live HTTP Headers]]></category>

		<guid isPermaLink="false">http://www.growlingranger.com/?p=455</guid>
		<description><![CDATA[So I had quite a specific problem. For some reason, http://growlingranger.com was redirecting to http://www.growlingranger.com with a 302 redirect. And, as SEO guru (and friend) Ken Jones from the SEOpsCentre put it, that&#8217;s bad SEO juju. 302 means that the address has moved temporarily, and will be back soon. Which in turn meant that my [...]]]></description>
			<content:encoded><![CDATA[<p>So I had quite a specific problem. For some reason, http://growlingranger.com was redirecting to http://www.growlingranger.com with a <a href="http://en.wikipedia.org/wiki/HTTP_302" target="_blank">302 redirect</a>. And, as SEO guru (and friend) Ken Jones from the <a href="http://www.seopscentre.com/" target="_blank">SEOpsCentre</a> put it, that&#8217;s bad SEO juju.</p>
<p>302 means that the address has moved temporarily, and will be back soon. Which in turn meant that my entire site (everything at www.growlingranger.com) was seen by Google and others as temporary. Bad juju indeed.</p>
<p>How do you know this? Well, I downloaded and installed a Firefox plugin called <a href="https://addons.mozilla.org/en-US/firefox/addon/3829" target="_blank">Live HTTP Headers</a>, which does exactly what it says on the packet. It gives you a feed of the HTTP headers as you load a page. And my headers had an ominous 302 redirect.</p>
<p>What I <em>need</em> is for it to be a <a href="http://en.wikipedia.org/wiki/HTTP_301" target="_blank">301 redirect</a>, which means the address has moved permanently and that any <a href="http://www.seopscentre.com/seo/how-to-explain-link-theory-to-a-layman/" target="_blank">lovely link juice</a> is passed on.</p>
<p>Now I tried everything to fix this, including my DNS entries. Scary stuff indeed. But nothing seemed to work. My hosting is with GoDaddy, so if you&#8217;ve also had this problem and you know why it happens then please let me know!</p>
<p>However, we were able to find a fix thanks to Ken Jones and his .htaccess awesomeness.</p>
<p>My .htaccess file already has some WordPress stuff in there, which looks like this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># BEGIN WordPress<br />
<br />
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule . /index.php [L]<br />
<br />
# END WordPress</div></td></tr></tbody></table></div>
<p>And that&#8217;s just doing funky things with my permalinks &#8211; how my blog has friendly URLs like http://www.growlingranger.com/2009/02/how-to-use-jquery-with-a-json-flickr-feed-to-display-photos/ instead of http://www.growlingranger.com/?p=455.</p>
<p>What we need to add was a bit of redirect code that takes anything and everything from http://growlingranger.com/ and forwards it <em><strong>permanently </strong></em>to http://www.growlingranger.com/.</p>
<p>And here it is:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>HTTP_HOST<span style="color: #009900;">&#125;</span> ^growlingranger<span style="color: #339933;">.</span>com <span style="color: #009900;">&#91;</span>NC<span style="color: #009900;">&#93;</span><br />
RewriteRule ^<span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span>$ http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.growlingranger.com/$1 [L,R=301]</span></div></td></tr></tbody></table></div>
<p>If you&#8217;ve experienced the same problem you can just replace &#8216;growlingranger&#8217; with whatever your domain is. If you&#8217;re successful you&#8217;ll get something like this in Live HTTP Headers&#8230;</p>
<p><a href="http://www.richardshepherd.com/wpblog/wp-content/uploads/2009/02/livehttpheaders1.jpg" target="_blank"><img class="alignnone size-medium wp-image-459" title="Live HTTP Headers" src="http://www.richardshepherd.com/wpblog/wp-content/uploads/2009/02/livehttpheaders-300x198.jpg" alt="Live HTTP Headers" /></a></p>
<p>Now I have restored my SEO juju, and it shouldn&#8217;t be long before Google catches up.</p>
<p>Ranger, out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardshepherd.com/htaccess-and-302-redirect-problems-fixed/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
