Usually after we upload the resource file, in order to avoid the file name conflict, the file name will be changed to a meaningless paragraph of characters. This character, which may be generated by MD5, or a string produced in other ways. At this time, when downloading, the default file name saved is this paragraph of meaningless filename (Figure 1).
In fact, Nginx is supported to rename the download, make the file name more friendly.
Nginx is also easy to configure: Just add the following lines:
Copy the code code as follows:
Location ~*. *\. (doc|txt|jar|zip|apk) (\?. *)?$
{
if ($request _uri ~* ^.*\/(. *) \. ( doc|txt|jar|zip|apk) (\?n= ([^&]+)) $) {
Add_header content-disposition "attachment;filename= $arg _n.$2";
}
Log_not_found off;
Expires 30d;
Break
}
If that line is more critical, so configuration, guaranteed not to pass n parameters, the original name is saved. No empty names appear.
Because it is specified in the header form, the CDN stores this header information, and the content is distributed in the same way.
Nginx: File download Specifies the configuration to save the file name