Skip to content

Instantly share code, notes, and snippets.

@rickharrison
Created September 2, 2013 07:41
Show Gist options
  • Save rickharrison/6410194 to your computer and use it in GitHub Desktop.
Save rickharrison/6410194 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;
}
}
@drKreso
Copy link

drKreso commented Apr 30, 2019

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment