-
-
Save shobhitsharma/174ba5d33c45e754d41a38ecb8ddc728 to your computer and use it in GitHub Desktop.
Nginx server config with clean URLs for Jekyll.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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