Skip to content

Instantly share code, notes, and snippets.

@mdunbavan
Forked from cmalven/craft-localization-nginx
Created September 21, 2016 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdunbavan/fbe651038e2bb57853b580e44d40f995 to your computer and use it in GitHub Desktop.
Save mdunbavan/fbe651038e2bb57853b580e44d40f995 to your computer and use it in GitHub Desktop.
nginx config for Craft CMS localization
server {
listen 80;
server_name site.production.designcompany.com;
root /home/forge/site.production.designcompany.com/public;
# enable gzip compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript image/svg+xml text/xml text/css;
gzip_vary on;
# end gzip configuration
# Increase max upload size
client_max_body_size 100m;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/epstein.production.onedesigncompany.com-error.log error;
error_page 404 /index.php;
# Start Localization Rewrites
location /es/ {
try_files $uri $uri/ @esrewrites;
}
location @esrewrites {
rewrite ^/es/(.*)$ /es/index.php?p=$1? last;
}
location @plrewrites {
rewrite ^/pl/(.*)$ /pl/index.php?p=$1? last;
} location /pl/ {
try_files $uri $uri/ @plrewrites;
}
location @plrewrites {
rewrite ^/pl/(.*)$ /pl/index.php?p=$1? last;
}
location @plrewrites {
rewrite ^/ro/(.*)$ /ro/index.php?p=$1? last;
} location /ro/ {
try_files $uri $uri/ @rorewrites;
}
location @rorewrites {
rewrite ^/ro/(.*)$ /ro/index.php?p=$1? last;
}
# End Localization Rewrites
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment