Making URL controller easy 3

Posted by Dan Sosedoff on January 15, 2009

For example, instead of using “dirty” url`s in your web application (like test.php?param=1&val=342&fuck=bla) you can use very nice links (/this/is/nice/link/). And also, redirect all the requests to single file.

nginx configuration:

location / {
    root /var/site/public_html;
    index index.php index.html index.htm;
    if (!-e $request_filename) {
        rewrite ^/(.*)/$ /index.php?path=$request_uri last;
    }
}

The same for Apache 2:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?path=%{REQUEST_URI} [NCL]