Altering Static File Handling
Table of Contents
MageStack treats dynamic content different to static content,
Eg.
- Different HTTP timeouts
- Different caching rules
- Different DOS rules
- etc.
Static files by default are defined here
To override the default behavior of a 404
error on non-existent static content (eg. for Magento downloadable content), you can either add a location directive, or add a rewrite rule. A rewrite rule is simpler and is preferred.
Examples
Change pdf
handling to fallback to Magento
Eg. For https://www.example.com/downloads/extra/path/information/here/filename.pdf
Via rewrite
rewrite ^/downloads/.+\.pdf$ index.php$is_args$args last;
Via location directive
location ~* ^/downloads/.+\.pdf$ {
location ~* \.(php)$ {
include fastcgi_params;
}
try_files $uri $uri/ index.php$is_args$args;
}
Change jpg
, gif
and svg
handling to fallback to Magento
Eg. For the following URLs
- https://www.example.com/downloads/extra/path/information/here/filename.pdf
- https://www.example.com/downloads/extra/path/information/here/filename.gif
- https://www.example.com/otherpath/extra/path/information/here/filename.svg
Via rewrite
rewrite ^/(downloads|otherpath)/.+\.(pdf|gif|svg)$ index.php$is_args$args last;
Via location directive
location ~* ^/(downloads|otherpath)/.+\.(pdf|gif|svg)$ {
location ~* \.(php)$ {
include fastcgi_params;
}
try_files $uri $uri/ index.php$is_args$args;
}