Skip to content

Instantly share code, notes, and snippets.

@briezler
Last active June 30, 2017 15:59
Show Gist options
  • Save briezler/12ac909ad1221786e9f11c49fda0fd6b to your computer and use it in GitHub Desktop.
Save briezler/12ac909ad1221786e9f11c49fda0fd6b to your computer and use it in GitHub Desktop.
Nginx Config Kirby
# Don't hint these as folders
rewrite ^/(content|site|kirby)$ /error last;
# block content
rewrite ^/content/(.*).(txt|md|mdown)$ /error last;
# block all files in the site and kirby folder from being accessed directly
rewrite ^/(site|kirby)/(.*)$ /error last;
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# panel links
location ~ /panel {
try_files $uri $uri/ /panel/index.php?$uri&$args;
}
# site links
location ~ / {
try_files $uri $uri/ /index.php?$uri&$args;
}
# Prevent clients from accessing hidden files (starting with a dot)
# This is particularly important if you store .htpasswd files in the site hierarchy
location ~ (?:^|/)\. {
deny all;
}
# Prevent clients from accessing to backup/config/source files
location ~ (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ {
deny all;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment