title: Yii and .htaccess file on production server
body: <p>I am new to yii and have some problem in configuring .htaccess file on production server.</p>
  
  <p><strong>On localhost :</strong> </p>
  
  <p><strong>Location of Application :</strong> /www/connect_donors/</p>
  
  <p><strong>Default URL that yii provides is</strong>,</p>
  
  <pre><code>http://localhost/connect_donors/index.php?r=controllerId/functionName
  </code></pre>
  
  <p>We used the urlManager in /connect_donors/protected/config/main.php to configure the SEO friendly url's..</p>
  
  <pre><code>'&lt;controller:\w+&gt;/&lt;id:\d+&gt;' =&gt; '&lt;controller&gt;/view',
  '&lt;controller:\w+&gt;/&lt;action:\w+&gt;/&lt;id:\d+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;',
  '&lt;controller:\w+&gt;/&lt;action:\w+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;'
  </code></pre>
  
  <p>Now the URL that was working was</p>
  
  <pre><code>http://localhost/connect_donors/index.php/controllerId/functionName
  </code></pre>
  
  <p>Then I used the .htaccess file to remove index.php from the above URL.</p>
  
  <p>Location of .htaccess is : /connect_donors/.htaccess</p>
  
  <p>Following is .htaccess file,</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /connect_donors
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
  </code></pre>
  
  <p><strong>URL Chenged to :</strong> </p>
  
  <pre><code>http://localhost/connect_donors/controllerId/functionName
  </code></pre>
  
  <p>Everything working fine and awesome.</p>
  
  <p>But yesterday I uploaded the application on production server.</p>
  
  <p><strong>On Production Server</strong></p>
  
  <p>Everything remained same only I had to change the .htaccess file.</p>
  
  <p>The .htaccess file on server is,</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
  </code></pre>
  
  <p>Now the following url:</p>
  
  <pre><code>http://donorsconnect.com/
  </code></pre>
  
  <p>loads the home page of server properly.</p>
  
  <p>But,
      <a href="http://donorsconnect.com/profile" rel="nofollow">http://donorsconnect.com/profile</a> </p>
  
  <p>redirects again to home page.</p>
  
  <p>NOTE : There is no session set on the "profile" controller.</p>
  
  <pre><code>class ProfileController extends CController
  {
      public function actionIndex()
      {
          $this-&gt;render('index');
      }
  }
  </code></pre>
  
  <p>I tried lot of things, changing the .htaccess file to different codes. but none helped me.</p>
  
  <p>Any help is appreciable.</p>
  
  <p><strong>Solution</strong></p>
  
  <p>I finally got the solution and the mistake I had done.</p>
  
  <p>My Components had a request array containing baseUrl.</p>
  
  <pre><code>'components'=&gt;array(
          ...
          'request' =&gt; array(
              'baseUrl' =&gt; 'http://donorsconnect.com',
          ...),
  </code></pre>
  
  <p>Due to this it was not loading. I did not find the real reason for that.</p>
  
  <p>But after removing that 'request' array, its loading fine.</p>
  
  <p>Check link,
  <a href="http://donorsconnect.com/profile" rel="nofollow">http://donorsconnect.com/profile</a></p>