Commit f81d4a8d authored by omega8cc's avatar omega8cc

Nginx: Use Redirect 301 for legacy paths /sites/default/files/* to /sites/foo.com/files/*

parent a9e3767b
......@@ -382,6 +382,7 @@ location ~* /(?:external|system|files/imagecache|files/styles)/ {
log_not_found off;
expires 30d;
# fix common problems with old paths after import from standalone to Aegir multisite
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
rewrite ^/sites/(.*)/files/imagecache/(.*)/sites/default/files/(.*)$ /sites/$server_name/files/imagecache/$2/$3 last;
rewrite ^/sites/(.*)/files/imagecache/(.*)/files/(.*)$ /sites/$server_name/files/imagecache/$2/$3 last;
rewrite ^/files/imagecache/(.*)$ /sites/$server_name/files/imagecache/$1 last;
......@@ -586,8 +587,9 @@ location ~* ^.+\.(?:jpe?g|gif|png|ico|bmp|svg|swf|docx?|xlsx?|pptx?|tiff?|txt|rt
log_not_found off;
add_header Access-Control-Allow-Origin *;
rewrite ^/images/(.*)$ /sites/$server_name/files/images/$1 last;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
rewrite ^/.+/sites/.+/files/(.*)$ /sites/$server_name/files/$1 last;
rewrite ^/odules/civicrm/(.*)$ /sites/all/modules/civicrm/$1 last;
rewrite ^/odules/civicrm/(.*)$ /sites/all/modules/civicrm/$1 last;
try_files $uri =404;
}
......@@ -600,6 +602,7 @@ location ~* ^.+\.(?:avi|mpe?g|mov|wmv|ogg|ogv|zip|tar|t?gz|rar|dmg|exe|apk|pxl|i
tcp_nodelay off;
tcp_nopush off;
add_header Access-Control-Allow-Origin *;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
rewrite ^/.+/sites/.+/files/(.*)$ /sites/$server_name/files/$1 last;
try_files $uri =404;
}
......@@ -616,6 +619,7 @@ location ~* ^/sites/.+/files/.+\.(?:pdf|aspx?)$ {
access_log off;
log_not_found off;
add_header Access-Control-Allow-Origin *;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
try_files $uri =404;
}
......@@ -628,6 +632,7 @@ location ~* ^.+\.flv$ {
tcp_nodelay off;
tcp_nopush off;
expires 30d;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
try_files $uri =404;
}
......@@ -642,6 +647,7 @@ location ~* ^.+\.(?:mp4|m4a)$ {
tcp_nodelay off;
tcp_nopush off;
expires 30d;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
try_files $uri =404;
}
......@@ -703,6 +709,7 @@ location ~* ^/sites/.*/files/ {
access_log off;
tcp_nodelay off;
expires 30d;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
try_files $uri =404;
}
......
......@@ -368,6 +368,7 @@ location ~* /(?:external|system|files/imagecache|files/styles)/ {
log_not_found off;
expires 30d;
# fix common problems with old paths after import from standalone to Aegir multisite
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
rewrite ^/sites/(.*)/files/imagecache/(.*)/sites/default/files/(.*)$ /sites/$server_name/files/imagecache/$2/$3 last;
rewrite ^/sites/(.*)/files/imagecache/(.*)/files/(.*)$ /sites/$server_name/files/imagecache/$2/$3 last;
rewrite ^/files/imagecache/(.*)$ /sites/$server_name/files/imagecache/$1 last;
......@@ -573,8 +574,9 @@ location ~* ^.+\.(?:jpe?g|gif|png|ico|bmp|svg|swf|docx?|xlsx?|pptx?|tiff?|txt|rt
log_not_found off;
add_header Access-Control-Allow-Origin *;
rewrite ^/images/(.*)$ /sites/$server_name/files/images/$1 last;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
rewrite ^/.+/sites/.+/files/(.*)$ /sites/$server_name/files/$1 last;
rewrite ^/odules/civicrm/(.*)$ /sites/all/modules/civicrm/$1 last;
rewrite ^/odules/civicrm/(.*)$ /sites/all/modules/civicrm/$1 last;
try_files $uri =404;
}
......@@ -587,6 +589,7 @@ location ~* ^.+\.(?:avi|mpe?g|mov|wmv|ogg|ogv|zip|tar|t?gz|rar|dmg|exe|apk|pxl|i
tcp_nodelay off;
tcp_nopush off;
add_header Access-Control-Allow-Origin *;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
rewrite ^/.+/sites/.+/files/(.*)$ /sites/$server_name/files/$1 last;
try_files $uri =404;
}
......@@ -603,6 +606,7 @@ location ~* ^/sites/.+/files/.+\.(?:pdf|aspx?)$ {
access_log off;
log_not_found off;
add_header Access-Control-Allow-Origin *;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
try_files $uri =404;
}
......@@ -615,6 +619,7 @@ location ~* ^.+\.flv$ {
tcp_nodelay off;
tcp_nopush off;
expires 30d;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
try_files $uri =404;
}
......@@ -629,6 +634,7 @@ location ~* ^.+\.(?:mp4|m4a)$ {
tcp_nodelay off;
tcp_nopush off;
expires 30d;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
try_files $uri =404;
}
......@@ -690,6 +696,7 @@ location ~* ^/sites/.*/files/ {
access_log off;
tcp_nodelay off;
expires 30d;
rewrite ^/sites/default/files/(.*)$ $scheme://$host/sites/$server_name/files/$1 permanent;
try_files $uri =404;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment