title: username rewriting taking last /
body: <p>What I've been trying to do is to rewrite url from domain.com?profile.php?id=foo to domain.com/foo and this condition works, and in the php to get the username i use</p>
  
  <pre><code>$_GET['id']
  </code></pre>
  
  <p>And it works untill i add another / at the end of url, for example if i want to make something like domain.com/user/photos or just domain.com/user/ then $_GET['id'] gets user/ instead of only user, I hope you understand what I'm trying to do.</p>
  
  <p>.htaccess</p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule ^([^.]+)$ $1.php [NC,L]
  
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([^.]+)([^/]+)$ profile.php?id=$1 [L]
  
  
  DirectoryIndex home.php
  </code></pre>
  
  <p>profile.php</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  require 'db.php';
  
  include_once('assets/language.php');
  include_once 'languages/'.$langfile;
  
  
  // Processing post and registering user
  include('assets/posts.php');
  
  $pageTitle = $_GET['id'];
  include('functions/functions.php');
  include('assets/header.php');
  
  if(!logged_in()) 
  {
      header("location: home");
      exit();
  }
  
  if(isset($_GET['id']))
  {
      $username = $_GET['id'];
  
      $stmt = $connection-&gt;prepare("SELECT * FROM users WHERE username = :username");
      $stmt-&gt;bindParam(':username', $username, PDO::PARAM_STR);
      $stmt-&gt;execute();
  
      if($stmt-&gt;rowCount() &gt; 0)
      {
          $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
          include('assets/content/view_profile.php');
      }
      else
      {
          header("location: home");
          exit();         
      }
  } 
  else
  {
      header("location: home");
      exit();
  }
  
  ?&gt;
  </code></pre>