title: How to pass a Persian string as a argument in the URL?
body: <p>I have a URL like this pattern:</p>
  
  <pre><code>www.example.com/ClassName/MethodName/Arg1/Arg2
  </code></pre>
  
  <p>Also here is my <code>.htaccess</code> file:</p>
  
  <pre><code>RewriteEngine on
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
  
  ErrorDocument 404 /error404.html
  </code></pre>
  
  <p>And this is my routing system:</p>
  
  <pre><code>if (empty($_GET['rt'])) {
      require_once('application/home.php');
  } else {
      require_once('application/search.php');
      $url  =  rtrim ($_GET['rt'], '/');
      $url  =  explode('/', $url);
  
      $ClassName  =   array_shift($url);
      $MethodName =   array_shift($url);
      $Arg1       =   array_shift($url);
      $Arg2       =   array_shift($url);
  }
  </code></pre>
  
  <hr>
  
  <p>Now what is the problem? Well, Everything is fine ..! Routing is completely fine for every URLs <strong>except</strong> when I use <code>م</code> in the URL. <em>(<code>م</code> is a Persian character)</em></p>
  
  <p><strong>For e.g.</strong></p>
  
  <pre><code>www.example.com/ClassName/Methodname/124/روز خوب      // it is fine
  www.example.com/ClassName/Methodname/254/سلام بر       // it isn't fine
  //                       because there is م ^ in the URL
  </code></pre>
  
  <p>So when I use <code>م</code> in the URL, I will faced with 404 Not Found page:</p>
  
  <p><a href="https://i.stack.imgur.com/34eGS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/34eGS.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>Well, I don't know that problem comes from where .. do you know? And how can I fix it? Is it a encoding issue? Or what?</p>
  
  <p><strong>Note:</strong> I use Xampp v3.2.1 (apache).</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> As mentioned in the comment, I add these two examples:</p>
  
  <pre><code>&lt;?php
  
  $str = "www.example.com/ClassName/Methodname/124/روز خوب";
  $url = explode('/', $str);
  echo "&lt;pre&gt;";
  print_r($url);
  
  /*
  Array
  (
      [0] =&gt; www.example.com
      [1] =&gt; ClassName
      [2] =&gt; Methodname
      [3] =&gt; 124
      [4] =&gt; روز خوب
  )
  */
  </code></pre>
  
  <p>Two: <em>(this directs to 404 Not Found)</em></p>
  
  <pre><code>&lt;?php
  
  $str = "www.example.com/ClassName/Methodname/254/سلام بر";
  $url = explode('/', $str);
  echo "&lt;pre&gt;";
  print_r($url);
  
  /*    
  Array
  (
      [0] =&gt; www.example.com
      [1] =&gt; ClassName
      [2] =&gt; Methodname
      [3] =&gt; 254
      [4] =&gt; سلام بر
  )
  */
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT2:</strong> According to a few tests, I figured out  the script that should get called by my rewriting rules (<code>index.php</code>), it even doesn't get call.</p>
  
  <hr>
  
  <p><strong>EDIT3:</strong> I enabled rewrite logging on Apache and when I check the result, there is a interesting thing: </p>
  
  <p><em>(These two samples aren't related to the above examples)</em></p>
  
  <p>Working routing sample:</p>
  
  <pre><code>[Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] add path info postfix: C:/xampp/htdocs/myweb/islamic_sources -&gt; C:/xampp/htdocs/myweb/islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] strip per-dir prefix: C:/xampp/htdocs/myweb/islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa -&gt; islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] applying pattern '^(.*)$' to uri 'islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa', referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] RewriteCond: input='C:/xampp/htdocs/myweb/islamic_sources' pattern='!-f' =&gt; matched, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] RewriteCond: input='C:/xampp/htdocs/myweb/islamic_sources' pattern='!-d' =&gt; matched, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace2] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] rewrite 'islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa' -&gt; 'index.php?rt=islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa', referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] split uri=index.php?rt=islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa -&gt; uri=index.php, args=rt=islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] add per-dir prefix: index.php -&gt; C:/xampp/htdocs/myweb/index.php, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace2] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] strip document_root prefix: C:/xampp/htdocs/myweb/index.php -&gt; /myweb/index.php, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] internal redirect with /myweb/index.php [INTERNAL REDIRECT], referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c8b0/initial/redir#1] [perdir C:/xampp/htdocs/myweb/] strip per-dir prefix: C:/xampp/htdocs/myweb/index.php -&gt; index.php, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c8b0/initial/redir#1] [perdir C:/xampp/htdocs/myweb/] applying pattern '^(.*)$' to uri 'index.php', referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c8b0/initial/redir#1] [perdir C:/xampp/htdocs/myweb/] RewriteCond: input='C:/xampp/htdocs/myweb/index.php' pattern='!-f' =&gt; not-matched, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c8b0/initial/redir#1] [perdir C:/xampp/htdocs/myweb/] pass through C:/xampp/htdocs/myweb/index.php, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.470250 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c1b8/initial] [perdir C:/xampp/htdocs/myweb/] strip per-dir prefix: C:/xampp/htdocs/myweb/fonts/taha/QuranTaha.woff -&gt; fonts/taha/QuranTaha.woff, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.470250 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c1b8/initial] [perdir C:/xampp/htdocs/myweb/] applying pattern '^(.*)$' to uri 'fonts/taha/QuranTaha.woff', referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.470250 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c1b8/initial] [perdir C:/xampp/htdocs/myweb/] RewriteCond: input='C:/xampp/htdocs/myweb/fonts/taha/QuranTaha.woff' pattern='!-f' =&gt; not-matched, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  [Sat Jan 02 22:17:00.470250 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c1b8/initial] [perdir C:/xampp/htdocs/myweb/] pass through C:/xampp/htdocs/myweb/fonts/taha/QuranTaha.woff, referer: http://localhost/myweb/search?s=islamic_sources&amp;q=%D8%B3%D9%84%D8%A7%D9%85
  </code></pre>
  
  <p>Not working (redirects to 404 not found) sample:</p>
  
  <pre><code>[Sat Jan 02 22:07:09.734092 2016] [rewrite:trace3] [pid 3188:tid 1712] mod_rewrite.c(475): [client ::1:64955] ::1 - - [localhost/sid#c397b0][rid#83ec138/initial] [perdir C:/xampp/htdocs/myweb/] add path info postfix: C:/xampp/htdocs/myweb/islamic_sources -&gt; C:/xampp/htdocs/myweb/islamic_sources/sahifeh_sajadiyeh/306/\xd9\x85\xd8\xa8
  [Sat Jan 02 22:07:09.734092 2016] [rewrite:trace3] [pid 3188:tid 1712] mod_rewrite.c(475): [client ::1:64955] ::1 - - [localhost/sid#c397b0][rid#83ec138/initial] [perdir C:/xampp/htdocs/myweb/] strip per-dir prefix: C:/xampp/htdocs/myweb/islamic_sources/sahifeh_sajadiyeh/306/\xd9\x85\xd8\xa8 -&gt; islamic_sources/sahifeh_sajadiyeh/306/\xd9\x85\xd8\xa8
  [Sat Jan 02 22:07:09.734092 2016] [rewrite:trace3] [pid 3188:tid 1712] mod_rewrite.c(475): [client ::1:64955] ::1 - - [localhost/sid#c397b0][rid#83ec138/initial] [perdir C:/xampp/htdocs/myweb/] applying pattern '^(.*)$' to uri 'islamic_sources/sahifeh_sajadiyeh/306/\xd9\x85\xd8\xa8'
  [Sat Jan 02 22:07:09.734092 2016] [rewrite:trace1] [pid 3188:tid 1712] mod_rewrite.c(475): [client ::1:64955] ::1 - - [localhost/sid#c397b0][rid#83ec138/initial] [perdir C:/xampp/htdocs/myweb/] pass through C:/xampp/htdocs/myweb/islamic_sources
  </code></pre>
  
  <p><strong>Interesting point:</strong> when routing is fine, that Persian string will be like this: (just decode):</p>
  
  <pre><code>%D8%B3%D9%84%D8%A7%D9%85
  </code></pre>
  
  <p>But when routing is 404 not found, the Persian string will be like this:</p>
  
  <pre><code>\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa
  </code></pre>
  
  <p>Seems there is two different kinds of encoding ..</p>