title: Encoding an url correctly while using a rewrite engine
body: <p>I am using a mod_rewrite and a routing system extracted from Akelos Framework.</p>
  
  <p>I have a very big problem while using some symbols in a search key parameter.</p>
  
  <p>A routing map is following:</p>
  
  <pre><code>$map-&gt;connect(":lang/search/:string", array('controller' =&gt; 'search','action' =&gt; 'index'));
  </code></pre>
  
  <p>In controller now I get <code>$this-&gt;registry-&gt;map['params']['get']['string']</code> as a search keyword.</p>
  
  <p>I can't find a way to properly encode a url. For example let's take a string <code>t\ /#%&amp;=</code></p>
  
  <p><code>urlencode()</code> gives <code>t%5C+%2F%23%25%26%3D</code> and page displays <code>The requested URL /site/en/search/t\+/#%&amp;= was not found on this server.</code></p>
  
  <p><code>rawurlencode()</code> gives <code>t%5C%20%2F%23%25%26%3D</code> and page displays the same.</p>
  
  <p>You can download or view a router class source <a href="https://docs.google.com/file/d/0B3-UiPvnVn9nWTg0YmQ1X1VGVnM/edit">here on this page</a></p>
  
  <p>I really do not want to use base64 for url and such encodings by which you can't read anything.</p>
  
  <p>In case if you need here is a <code>.htaccess</code> file contents as well:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p><a href="https://docs.google.com/file/d/0B3-UiPvnVn9nWTg0YmQ1X1VGVnM/edit">Here are actually working files for making tests.</a></p>
  
  <p>Please download these files and test on your server if you have time.</p>
  
  <p><strong>Guide:</strong></p>
  
  <p><code>controllerclass.php</code> - Simple controller framework, enables searchcontroller.php to work by defining a class "Controller" in it</p>
  
  <p><code>routerclass.php</code> - A router class extracted from Akelos Framework, bug is probably there</p>
  
  <p><code>routes.php</code> - A place where you define your routs, in our case we have only <code>/search/:string</code></p>
  
  <p><code>searchcontroller.php</code> - A basic application to test strings - /search/stringhere points to this file</p>
  
  <p><code>index.php</code> - Where all the initiation and routing happens to begin</p>
  
  <p><code>.htaccess</code> - I do not think an error is here</p>
  
  <p>I think you won't need to make changes in <code>index.php</code>, <code>controllerclass.php</code>, <code>routes.php</code>, <code>searchcontroller.php</code></p>
  
  <p>A bug is probably in <code>routerclass.php</code> or maybe there is some fix needed in <code>.htaccess</code> which I don't believe.</p>