+1  A: 

This is what I have in my .htaccess for my framework:

<IfModule mod_rewrite.c>
    RewriteEngine on

    #This will stop processing if it's images
    RewriteRule \.(css|jpe?g|gif|png|js)$ - [L] 

    #Redirect everything to apache
    #If the requested filename isn’t a file….
    RewriteCond %{REQUEST_FILENAME} !-f
    #and it isn’t a folder…
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php?$1 [L,QSA] 
    #L = (last - stop processing rules)
    #QSA = (append query string from requeste to substring URL)
</IfModule>

Hope this helps.

PS: Maybe you want to remove the lines to stop redirecting if it's a file or folder ;)

AntonioCS
I want all routes that aren't in these whitelisted directories to go to "index.php/request/uri" explicitly. Otherwise, if they so desire they can view my controllers.
The Wicked Flea
A: 

Antonio helped me get on the right track, so here's the resulting .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine on
  # skip if whitelisted directory
  RewriteRule ^(images|css|js|robots\.txt|index\.php) - [L]
  # rewrite everything else to index.php/uri
  RewriteRule . index.php%{ENV:REQUEST_URI} [NE,L]
</IfModule>
The Wicked Flea
A: 

You're going to have to do that using PHP. For example, if you wanted to split your URI into something like domain.tld/controller/action/param, then you could use the following PHP code as a start:

<?php

// Filter URI data from full path
$uri_string = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']);
$uri_string = trim($uri_string, '/');    // Make sure we don't get empty array elements

// Retrieve URI data
$uri_data = explode('/', $uri_string);

In that case, $uri_data[0] is the controller, $uri_data[1] is the action, and beyond that are parameters. Note that this isn't a foolproof method, and it's never a great idea to trust user-entered input like this, so you should whitelist those controllers and actions which can be used.

From here, knowing the controller and having a consistent directory structure, you can require_once the proper controller and call the action using variable variables.

Andrew Noyes
I already have the code that handles the URI parsing, I just needed to get .htaccess working to protect my sensitive directories and tidy the url a bit.
The Wicked Flea
Oh okay, I misunderstood your question. I thought you were trying to actually have the URI processed using .htaccess.
Andrew Noyes