For work reasons, it is necessary to add the download function to the original nginx server. Add the server configuration in nginx.conf as follows:
The directory for downloading files is placed under download in the project root directory:
if ( $uri ~* "^/ download/.*" ) {
break; Then add a location that matches download. This location should be placed before matching all locations / .
location ~* "^/download/.*" {
header Content-Type 'application/ OCTET-Stream; Charset = UTF-8 ';Add_header Content-Transfer-encoding' Binary ';
error_page 404 http://weibo.com/sorry ;}
Add_header Sponse head information.
After matching a location, the matching will not continue.
The above has introduced some issues with nginx configuration, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.