I'm trying to set-up nginx rewrite rules as the following:
Original structure:
domain.com/index.php?site=project
Now I tried to mask it using the nginx rewrite engine:
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
rewrite ^/(.+)$ /index.php?site=$1 last;
break;
}
How do I forbid folders (stuff ending with a slash) and non-existent files? I read a lot about
try_files
but I can't get it to work.
at the moment I have
try_files $uri $uri/ @app;
and
location @app {
rewrite ^/ /404.php last;
}
but it won't work. What am I doing wrong?
Also: Do I need to alter my PHP code? Or is pure rewrite fine?