Mod Rewrite,忽略目录,除非URL有一个尾部斜杠

I am making an url shortener with a base 64 encoding for my urls. problem is I also have a bunch of folders inside my main directory. My directory looks something like this

/
  /css
    style.css
  /handlers
    handle_database.php
  index.php
  .htaccess

And this is the rewrite rule I use to capture the encoded urls

RewriteRule ^([A-Za-z0-9_\-]{3,8})$ index.php?a=$1

And that works. my problem comes when my system generates an url that would be like this http://exampleurlshortener.com/css, in an ideal scenario the rewrite rule would capture the "css" and let my index.php handle the rest, problem is apache adds a trailing slash and it ends up getting inside the css directory.

So what I need is that http://exampleurlshortener/css -> lets index.php handle the request http://exampleurlshortener/css/ -> access the actual directory

So far I've had no luck, because apache keeps adding the trailing slash

You need to turn off DirectorySlash to avoid Apache adding a trailing slash. It is also important to turn off Indexes option to avoid Apache presenting directory listing to users.

DirectorySlash off
Options -Indexes
DirectoryIndex index.php

RewriteEngine On

RewriteRule ^([\w-]{3,8})$ index.php?a=$1 [L,QSA]