javascript encode url for url rewrite context and php decode it
<p>I have a pattern of my page as following: <code>search/:key</code> it means that if browser is pointed to <code>http://..../.../search/cat</code> then <code>cat</code> will be recognized as search keyword and will be further searched by server-side.</p>

<p>A problem is that if you go <code>http://..../.../search/keywi/th/slash</code> then only part of it will be recognized as key <code>keywi</code>, so I want to encode it in a way that even large html portions would be processed as a search keyword. For example <code>http://..../.../search/first!@#$!@":;/\asd/&lt;b&gt;hello&lt;/b&gt;everythign&lt;script&gt;&lt;/script&gt;</code>.</p>

<p>A client-side code:</p>

<pre><code>$("#search-form").submit(function(){
    var key = $("#key").val(); // Encode Here
    window.location = "/search/"+key;
    return false;
});
</code></pre>

<p>A server-side code:</p>

<pre><code>$key = $_GET['key']; // Decode here
</code></pre>

<p>Thanks.</p>
