<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Eschew Obfuscation: Apache Redirects to the Rescue</title>
    <link>http://blog.maxdunn.com/articles/2006/10/07/apache-redirects-to-the-rescue</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Max Dunn's Personal Blog</description>
    <item>
      <title>Apache Redirects to the Rescue</title>
      <description>&lt;p&gt;There are a couple of technical problems with my web site. The first is that to get into this blog, you need to add the trailing slash at the end of &amp;#8220;typo&amp;#8221; like this: &lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;http://www.maxdunn.com/typo/&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Otherwise, the wiki gives a page not found error for the &amp;#8220;typo&amp;#8221; page. Of course, when most people type in the &lt;span class="caps"&gt;URL&lt;/span&gt; manually, they won&amp;#8217;t add the trailing slash and then get confused when it doesn&amp;#8217;t pull up my blog.&lt;/p&gt;


	&lt;p&gt;I have tried various things in the Rails routing.rb file to correct for this, but none worked. However, a simple change to .htaccess did the trick:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;RedirectMatch permanent ^/typo$ http://www.maxdunn.com/typo/&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Now another problem I have is that my &lt;span class="caps"&gt;ISP&lt;/span&gt; &lt;a href="http://www.site5.com"&gt;Site5&lt;/a&gt; maps maxdunn.com to www.maxdunn.com and there is no way to turn this off. This causes several problems:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;When logged into &lt;strong&gt;www.maxdunn.com&lt;/strong&gt;, you won&amp;#8217;t be logged in if you access it as &lt;strong&gt;maxdunn.com&lt;/strong&gt;.&lt;/li&gt;
		&lt;li&gt;If someone first accesses the site using &lt;strong&gt;maxdunn.com&lt;/strong&gt;, then the page cache will create all links as &lt;strong&gt;maxdunn.com&lt;/strong&gt; and serve these up, even if the page is later accessed as &lt;strong&gt;www.maxdunn.com&lt;/strong&gt;.&lt;/li&gt;
		&lt;li&gt;If the site is accessed with both &lt;strong&gt;maxdunn.com&lt;/strong&gt; and &lt;strong&gt;www.maxdunn.com&lt;/strong&gt;, then Google and other search engines will think these are two sites and neither will be ranked as highly.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;To fix this problem, there is another simple .htaccess addition that will redirect all &lt;strong&gt;maxdunn.com&lt;/strong&gt; requests to &lt;strong&gt;www.maxdunn.com&lt;/strong&gt;:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;RewriteCond %{HTTP_HOST} ^maxdunn.com$ [NC]
RewriteRule ^(.*)$ http://www.maxdunn.com/$1 [L,R=301]&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Sat, 07 Oct 2006 12:36:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:842caffa-e0d2-44de-beef-56bfb91796db</guid>
      <author>Max Dunn</author>
      <link>http://blog.maxdunn.com/articles/2006/10/07/apache-redirects-to-the-rescue</link>
      <category>Ruby on Rails</category>
      <category>Tech Tips</category>
    </item>
  </channel>
</rss>
