Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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..

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

2 Answers 2

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. https://github.com/nhnc-nginx/apache2nginx/wiki/Welcome-to-Apache2Nginx

share|improve this answer

Your Answer

 
discard

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.