Skip to content

Instantly share code, notes, and snippets.

@cmalven
Last active October 22, 2019 12:59
Show Gist options
  • Save cmalven/5cc95cce4e495d3a11df to your computer and use it in GitHub Desktop.
Save cmalven/5cc95cce4e495d3a11df 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