Using pretty URLs in concrete5 with Nginx

The Nginx web server is becoming ever more popular as an alternative to Apache. Especially if you want to use the PHP FastCGI Process Manager (php-fpm) that shipped with PHP 5.3.3.

Lately I have been using the concrete5 CMS a lot. It offers an option to use pretty URLs, but only tells how to configure it for Apache. After reading the Nginx documentation and searching the web I came up with a simple configuration (tested with nginx-0.8.54).

http {
  include mime.types;
  default_type application/octet-stream;
  sendfile on;
  keepalive_timeout 65;
  access_log logs/access.log;
  index index.html index.php;

  #default server
  server {
    listen 80 default_server;
    server_name _;
    root html;

  server {
    root /srv/www/vhosts/;
    access_log logs/concrete5.access.log;

    location / {
      try_files $uri $uri/ /index.php/$request_uri;

    #pass PHP scripts to FastCGI server
    location ~ \.php($|/) {
      set $script $uri;
      if ($uri ~ "^(.+\.php)(/.+)") {
        set $script $1;

      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME $document_root$script;
      fastcgi_intercept_errors on;