Nginx rewrite rules for Joomla!

joomlanginxrewrite

I've got nginx installed on Ubuntu from the repository (v0.7.65), and while with my default site configuration works wonders with WordPress pretty URLs and nginx-compatibility plugin (so far), it doesn't with Joomla!. Here's the configuration:

server {
listen   80 default;
server_name  localhost;

access_log  /var/log/nginx/localhost.access.log;

root   /var/www/nginx-default;

location /wordpress {
    try_files $uri $uri/ @wordpress;
}

location /joomla {
    try_files $uri $uri/ @joomla;
}

# ConfiguraciĆ³n para instalaciones de WordPress
location @wordpress {
    fastcgi_pass   127.0.0.1:9120;
    fastcgi_param SCRIPT_FILENAME $document_root/wordpress/index.php;
    include fastcgi_params;
}

# ConfiguraciĆ³n para instalaciones de Joomla!
location @joomla {
    fastcgi_pass   127.0.0.1:9120;
    fastcgi_param SCRIPT_FILENAME $document_root/joomla/index.php;
    include fastcgi_params;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9120;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

}

I got it to show me the index, the administrator, and one level below links. That is, if I access /joomla/joomla-overview, it works just nice (with friendly URLs and Apache mod_rewrite enabled in Joomla!), but if I try /joomla/joomla-overview/what-is-new-in-1-5, I get an error.

What do you think is happening here? Do you know other settings to make it work, preferably within the environment I have it now?

Thanks in advance for your support.

PS: Please, I have not found much help relating my issue. I've tried different solutions, to no avail.

Best Answer

I'm not sure if this has been solved but this nginx config works for my joomla installation.

server {
  server_name example.com;
  rewrite ^ http://www.example.com$request_uri permanent;
 }
server {
  server_name www.example.com;
  root /home/public_html/example.com/public;
  error_page   404          /404.html;
  try_files $uri $uri/ /index.php?q=$request_uri;

  index index.php index.htm index.html;
  # serve static files directly
  location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires 30d;
  }
  location 404.html{
    index /404.html;
  }
  location ~* \.php$ {
    # By all means use a different server for the fcgi processes if you need to
    fastcgi_pass 127.0.0.1:9000;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
  }
  location ~ /\.ht {
    deny all;
  }
}