title: How to work with pretty URLs - PHP
body: <p>i followed up multiple tutorials how to make pretty URL but never actualy make it work (prolly i didnt get something).</p>
  
  <p><strong>What i want:</strong></p>
  
  <p>From something like this:</p>
  
  <pre><code>http://www.example.com/api/v1/get.php?user=UserName&amp;id=7Ka2la2
  </code></pre>
  
  <p>I want to make something like this:</p>
  
  <pre><code>http://www.example.com/UserName/get/7Ka2la2
  </code></pre>
  
  <p><strong>What i did try:</strong>
  As I mentioned I try to follow multiple tutorials but nothing worked for me. So i try something by my self.</p>
  
  <pre><code>//.htaccess
  &lt;IfModule mod_rewrite.c&gt;
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>What it does:</p>
  
  <ul>
  <li>it checks if the request filename isn't a file</li>
  <li>and checks if it isn't a directory</li>
  <li>then, the RewriteRule makes a call to index.php, no matter what was written in the URL</li>
  </ul>
  
  <p>And in my <code>index.php</code> file it looks like this</p>
  
  <pre><code>&lt;?php
  function parse_path() {
    $path = array();
    if (isset($_SERVER['REQUEST_URI'])) {
      $path = explode('/', $_SERVER['REQUEST_URI']);
    }
  return $path;
  }
  
  $path_info = parse_path();
  echo '&lt;pre&gt;'.print_r($path_info, true).'&lt;/pre&gt;';
  
  switch($path_info[1]) {
    case 'get': include 'get.php';
      break;
    default:
      include '404.php';
  }
  </code></pre>
  
  <p>So it basicly should just split url to array and then base on URL include right file (in this example its <code>get.php</code>). However like this i can load a file but i have nothing in my <code>$_GET</code> and <code>$_POST</code> which make my script useless for me.</p>
  
  <p><strong>Question:</strong>
  My code will somehow do what i want so base on url it load content but <code>$_GET</code> and <code>$_POST</code> will not work correctly here. So my question is did I make it wrong way? If yea how should looks the right one and if not how I can access <code>$_GET</code> and <code>$_POST</code> variabiles</p>