title: seo friendly urls in YII framework with id and name
body: <p>I've been searching all around Stackoverflow and YII forums, there are many answers,
  which didn't help me...</p>
  
  <p>This is my case. </p>
  
  <p>I have controller called: <strong>proj</strong> and an action called <strong>view</strong>.
  It gets: <strong>id</strong>(int), <strong>name</strong>(string).</p>
  
  <p>The desired name gets sometimes with special chars such as: [<strong>+,!#$%^&amp;*-</strong>]</p>
  
  <p>So when I'm running <strong>createUrl()</strong> function it returns me not so friendly url.</p>
  
  <p>For example:
  <a href="http://www.qa-mysite.com/proj/1029/Conservation+of+the+Vermont+Salt+Pan+System%2C+Hermanus%2C+South+Africa" rel="nofollow">http://www.qa-mysite.com/proj/1029/Conservation+of+the+Vermont+Salt+Pan+System%2C+Hermanus%2C+South+Africa</a>.</p>
  
  <p>id = 1029
  name = Conservation of the Vermont SaltPan System, Hermanus, South Africa.</p>
  
  <p>I want the result to be:
  <a href="http://www.qa-mysite.com/proj/1029/conservation-of-the-vermont-salt-pan-system-hermanus-south-Africa" rel="nofollow">http://www.qa-mysite.com/proj/1029/conservation-of-the-vermont-salt-pan-system-hermanus-south-Africa</a></p>
  
  <p>So actually i need to strip the special chars and change the delimiter between spaces to "-" instead of "+".</p>
  
  <p>My current configurations of the curlManager are:</p>
  
  <pre><code>'urlManager'=&gt;array(
              'urlFormat'=&gt;'path',
              'showScriptName'=&gt;false,
              'appendParams' =&gt; true,
              'rules'=&gt;array(
              //array('proj/view/&lt;name:\w+&gt;', 'pattern'=&gt;'proj/&lt;id:\d+&gt;'),
                  //'&lt;controller:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/view',
                  'proj/&lt;id:\d+&gt;/&lt;name:\w+&gt;'=&gt;array('proj/view', 'caseSensitive'=&gt;false),
                  '&lt;controller&gt;/&lt;id:\d+&gt;/&lt;name:.*?&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>CreateUrl example:</p>
  
  <pre><code>$this-&gt;createUrl('proj/view', array('id' =&gt; $data-&gt;id, 'name' =&gt; $data-&gt;name));
  </code></pre>
  
  <p>After the urls will be changed I need to do <strong>301 redirects</strong> of the old ones to the new-seo-friendly urls.</p>
  
  <p>Note: I cannot do hardcoded str_replace.</p>
  
  <p>Many thanks for any help :]</p>