Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just migrated a webserver from Apache to nginx and I can't get the .htaccess conversion to work properly. The app I'm trying to use is bamboo invoice [], and it comes with a default .htaccess which looks like this:

RewriteEngine on
RewriteRule ^$ /index.php [L]
RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico|update\.php|install\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]

Can anyone suggest how to translate this set of rewrite rules to an nginx format? I'm not having any luck..

share|improve this question
Does it need to be rewritten to keep the full path of the request with /index.php/ added in, or can it just be handled by index.php directly via try_files? – Shane Madden Jun 5 '12 at 16:54
I believe it needs to keep the path /index.php/ – user612063 Jun 5 '12 at 21:58

Try something like this:

location ~* (index\.php|img|css|js|robots\.txt|favicon\.ico|update\.php|install\.php) {
  try_files $uri =404;
location / {
  try_files /index.php$uri;

That match seems a little overly-permissive; a request for anything with "img", "js", or "css" anywhere in the path or filename will catch the static content rule.

share|improve this answer

There is now a tool named Apache2Nginx. It can help to migrate configuration files from Apache to Nginx.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.