Nginx rewrite rules for Symphony 2.0.6

from here.


server {
  listen 80;
  server_name localhost;

  access_log /path/to/log/access.log;
  error_log /path/to/log/error.log;

  location / {
    root   /path/to/root;
    index  index.php;

    # serve static files directly
    if (-f $request_filename) {
      access_log        off;
      expires           30d;
      break;
    }

    ### BACKEND
    if ($request_filename ~ /symphony/) {
      rewrite ^/symphony/?$ /index.php?mode=administration&$query_string last;
      rewrite ^/symphony(/(.*/?))?$ /index.php?symphony-page=$1&mode=administration&$query_string last;
    }

    ### IMAGE RULES
    rewrite ^/image/(.+\.(jpg|gif|jpeg|png|bmp|JPG|GIF|JPEG|PNG|BMP))$ /extensions/jit_image_manipulation/lib/image.php?param=$1 last;

    ### CHECK FOR TRAILING SLASH - Will ignore files
    if (!-f $request_filename) {
        rewrite ^/(.*[^/]+)$ /$1/ permanent;
    }

    ### MAIN REWRITE - This will ignore directories
    if (!-d $request_filename) {
        rewrite ^/(.*)$ /index.php?symphony-page=$1 last;
    }
  }

  location ~ \.php($|/) {
    fastcgi_index index.php;

    set  $script     $uri;
    set  $path_info  "";
    if ($uri ~ "^(.+\.php)(/.*)") {
      set  $script     $1;
      set  $path_info  $2;
    }
    fastcgi_pass   127.0.0.1:9000;
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  /path/to/root$script;
    fastcgi_param  PATH_INFO        $path_info;
    fastcgi_param  SCRIPT_NAME $script;
  }

  location ~ /\.ht {
    deny  all;
  }
}

Comments

The opinions expressed in comments are entirely the responsibility of the various contributors. While I will do everything within reason to ensure that they are not defamatory, I accept no liability for them or the content of links included in them.

Gravatar for fp fp (#1)

test

Leave a Comment

Before leaving a comment, please ensure you have read and understand my comments policy and my privacy policy. Any comment that does not abide by the comment policy will be deleted immediately.

Related Posts