title: Forced trailing slash with this .htaccess structure
body: <p>I using below PHP &amp; htacess codes for routing structure in my project, I would like to add forced trailing slash to all routes like that;</p>
  <p><code>localhost/project/about-us</code> &gt; <code>localhost/project/about-us/</code></p>
  <p>It's working on main path like <code>localhost/project/</code> so I cannot display main path without trailing slash like <code>localhost/project</code> because it's redirect me(that's what I want for all routes).</p>
  <p>How can I do that? Thanks. Codes:</p>
  <pre><code>function request_path()
  {
      $request_uri = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
      $script_name = explode('/', trim($_SERVER['SCRIPT_NAME'], '/'));
      $parts = array_diff_assoc($request_uri, $script_name);
      if (empty($parts))
      {
          return '/';
      }
      $path = implode('/', $parts);
      if (($position = strpos($path, '?')) !== FALSE)
      {
          $path = substr($path, 0, $position);
      }
      return $path;
  }
  
  $routes = [
    '/' =&gt; function()
    {
        echo 'home';
    },
    'about-us' =&gt; function()
    {
        echo 'about';
    },
    'profile/edit' =&gt; function()
    {
        echo 'profile edit';
    }
  ];
  
  $path = request_path();
  
  if (isset($routes[$path]) AND is_callable($routes[$path]))
  {
    $routes[$path]();
  }
  else
  {
    echo 404;
  }
  </code></pre>
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
  </code></pre>