URL Rewrite is not working in Nginx
Well @NanheKumar's answer got the rewrite correct but it ignored the first 2 rules in the htaccess
RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d
This means check if the request doesn't match a file and doesn't match a directory, to imitate this exact behavior you can use try_files
like this
location / { try_files $uri $uri/ /index.php?u=$request_uri;}
This will make sure to serve requests that point to an asset or a directory directly first then if neither it would pass the request to index.php
EDIT: unless index.php
is able to serve assets, this will cause all assets ( images, css, javascript, etc ) to show errors because index.php
will be receiving arguments it's not expecting. Think about something like this http://example.com/index.php?u=/images/background.jpg