title: WordPress blog on subdirectory .htaccess redirect
body: <p>I have a Joomla website on root-level, and wordpress blog on /blog . </p>
  
  <p>Inside root-level .htaccess, I need to implement non-www to www redirect, such as:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^example.com$
  RewriteRule (.*) http://www.example.com/$1 [R=301,L] 
  </code></pre>
  
  <p>However, this causes a problem when going to www.example.com/blog (withoug trailing "/" at the end). I get redirected to <a href="http://www.example.com/cgi-bin/php53.cgi/blog/index.php" rel="nofollow">http://www.example.com/cgi-bin/php53.cgi/blog/index.php</a></p>
  
  <p>The php53.cgi file is there to turn on PHP 5.3 version. This is the content of that file:</p>
  
  <pre><code>#!/bin/sh
  export PHP_FCGI_CHILDREN=3
  exec /hsphere/shared/php53/bin/php-cgi
  </code></pre>
  
  <p>This is the .htaccess inside /blog directory:</p>
  
  <pre><code># BEGIN WordPress
  &lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /blog/
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /blog/index.php [L]
  # END WordPress
  </code></pre>