I've got a PHP MVC framework I have constructed from scratch which utilizes the standard domain.com/controller/action URL routing. While I am presently handling the below conversion within the router Let me replace them within the URL for cosmetic reasons.

For instance:




I have done a little of experimentation having a regex but can't appear to locate a match. I am also unsure how you can rewrite it using RewriteCond.

Thanks ahead of time.

The Zend Framework URL format is almost just like this, and here's what they use:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

In case your server-side script is PHP, you could utilize this to seize the url parts:

$request_parts = explode('/', $_SERVER['REQUEST_URI']);
$controller = $request_parts[0];
$action = $request_parts[1];
// etc...

According to your reaction to my other answer, I suggest that you employ JavaScript to handle filter form submit and make the "clean url" request around the client side.


I lately implemented this on my small Year/Month picker for my calendar application. It uses jQuery/JavaScript to identify alterations in the shape and write the "clean" URL:

$(document).ready(function() {
    $('form.jumpform select').change(function() {
        $form = $(this).closest('form');
        window.location = $form.attr('action')
                + '/y/' + encodeURIComponent($form.find('select[name="y"]').val())
                + '/m/' + encodeURIComponent($form.find('select[name="m"]').val());