0

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 [http://bambooinvoice.org/], 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..

2
  • 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? Jun 5, 2012 at 16:54
  • I believe it needs to keep the path /index.php/
    – user612063
    Jun 5, 2012 at 21:58

2 Answers 2

1

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.

1

There is now a tool named Apache2Nginx. It can help to migrate configuration files from Apache to Nginx. https://github.com/nhnc-nginx/apache2nginx/wiki/Welcome-to-Apache2Nginx

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .