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]
Trackbacks

Trackbacks are closed.

Comments

Comments are closed.

  1. MechanisM Mon, 20 Apr 2009 10:09:07 CDT

    How 2 set up this config on Windows version of nginx?
    I mean this part [[[ location / {
    root /var/site/public_html; ]]]
    something like: root Z:/WWW; <– not working for me

  2. sosedoff Mon, 20 Apr 2009 11:37:48 CDT

    I never used nginx under windows, but i guess this is something about your problem – http://www.ruby-forum.com/topic/172663
    http://nicholasorr.com/blog/2008/11/22/solved-nginx-php-fastcgi-win32-no-input-file-specified/

    also, i checked out the wiki with small config example for windows: http://wiki.nginx.org/NginxMediaWiki

  3. MechanisM Mon, 20 Apr 2009 14:21:22 CDT

    Спасибо))