Skip to content

Instantly share code, notes, and snippets.

@shobhitsharma
Forked from rickharrison/jekyll.nginxconf
Created June 2, 2018 15:44
Show Gist options
  • Save shobhitsharma/174ba5d33c45e754d41a38ecb8ddc728 to your computer and use it in GitHub Desktop.
Save shobhitsharma/174ba5d33c45e754d41a38ecb8ddc728 to your computer and use it in GitHub Desktop.
Nginx server config with clean URLs for Jekyll.
server {
listen 80;
server_name www.yourdomain.com;
return 301 $scheme://yourdomain.com$request_uri;
}
server {
listen 80;
root /var/www/yourdomain.com;
index index.html index.htm;
server_name yourdomain.com;
access_log /var/log/nginx/yourdomain.com.log;
if (!-f "${request_filename}index.html") {
rewrite ^/(.*)/$ /$1 permanent;
}
if ($request_uri ~* "/index.html") {
rewrite (?i)^(.*)index\.html$ $1 permanent;
}
if ($request_uri ~* ".html") {
rewrite (?i)^(.*)/(.*)\.html $1/$2 permanent;
}
location / {
try_files $uri.html $uri $uri/ /index.html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment