Nginx 1.10.0 and php7 rewrites

I’m trying to install kirby and the config here:


is not working. Has anyone had any success using Kirby with the configuration?

This is a simplified version of what we use, hope it helps.

# domain.com
server {
  listen [::]:80;
  listen 80;
  server_name  domain.com;
  root        /var/www/domain;
  access_log  off;
  error_log  /var/www/logs/error.log crit;

  # You may want to look at h5pb for other stuff to put here:
  # https://github.com/h5bp/server-configs-nginx
  # ----------------------------
    

  # Character Set
  charset UTF-8;

  # php
  location ~\.php$ {
    # If php-fpm is communicating with nginx via TCP IP, then uncomment/comment next two lines
    # fastcgi_pass 127.0.0.1:9000;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
  

  # Kirby 
  # Cache Plugin
  location /assets {
    if (!-e $request_filename) {
      rewrite ^/(.+)\.(\d+)\.(js|css)$ /$1.$3 break;
    }
  }
  
  # block content
  location ~ ^/content/(.*).(txt|md|mdown)$ {
    rewrite ^/content/(.*).(txt|md|mdown)$ /error redirect;
  }

  # block all files in the site folder from being accessed directly
  location ~ ^/site/(.*)$ {
    rewrite ^/site/(.*)$ /error redirect;
  }

  # block all files in the kirby folder
  location ~ ^/kirby/(.*)$ {
    rewrite ^/kirby/(.*)$ /error redirect;
  }

  # site links
  location / {
    try_files $uri $uri/ /index.php?$uri&$args;
  }

  # panel links
  location /panel {
    try_files $uri $uri/ /panel/index.php?$uri&$args;
  }
  
  # Error pages
  error_page  404     /error;
  error_page  403     /error;

}# End domain.com
1 Like