Pipeline is a file name. Simply put, how can we implement this pseudo-static state? As long as the index. php file receives the xx. xxx parameter, we can {generation... ask how to implement it, such
Https://www.xxx.com/img/1015308c0ebce716.jpg
Where1015308c0ebce716.jpgIs a file name
To put it simply, how can we implement this pseudo-static state? As long as the index. php file receives the xx. xxx parameter?
$ _ SERVER [ORIG_PATH_INFO] // use this?
Taking into account a lot of files, such slice storage is definitely not easy to manage.
Therefore, we want to use a unique id as the file name during the upload process and store it in different folders at the same time.
Reply content:
How to implement it, such
Https://www.xxx.com/img/1015308c0ebce716.jpg
Where1015308c0ebce716.jpgIs a file name
To put it simply, how can we implement this pseudo-static state? As long as the index. php file receives the xx. xxx parameter?
$ _ SERVER [ORIG_PATH_INFO] // use this?
Taking into account a lot of files, such slice storage is definitely not easy to manage.
Therefore, we want to use a unique id as the file name during the upload process and store it in different folders at the same time.
"Pseudo-static" is actually a pseudo concept. In fact, through some technology, the client (usually a browser) considers it to be accessing a "static" resource, as mentioned by the subject in the descriptionhttps://www.xxx.com/img/1015308c0ebce716.jpg
It is the "dynamic" content returned by a PHP script. To do this, at least the following conditions must be met:
- The URL looks like a static file.
Content-Type
Tell the browser that it is a static file. As mentioned in the JPEG imageimage/jpeg
Here we assume that PHP and nginx are used:
Assume that/img/1015308c0ebce716.jpg
It is a PHP file, and nginx is told to handle the file in PHP, and the problem is solved. Obviously, this is not a very good idea. This design not only makes us confused, but limits the architecture of the application itself, and the passing of parameters is obviously hard. If we can access/img/1015308c0ebce716.jpg
When the request is sent to a PHP script, and part of the URL can be taken as a parameter, the problem is solved elegantly. In fact, nginx's ngx_http_rewrite_module can do this. (Apache can use mod_rewrite ). For example, assume that/img/1015308c0ebce716.jpg
The corresponding processing script is/index.php?mod=image&id=1015308c0ebce716
Andid
As a parameter, so:
nginx
server { root /path/to/app; rewrite ^/img/([a-z\d]+)\.jpg$ /index.php?mod=image&id=$1 last; location /index.php { ... ... }}
- Solve the previous problem, and this is a good solution. If it is a PHP script, use it directly here.
header('Content-Type: image/jpeg')
Okay.
Finally, the subject mentioned$_SERVER[ORIG_PATH_INFO]
It can appear as a form of passing parameters to the PHP script, or even as a part of the overall design and implementation of the URL on the architecture. Here, you can refer to ThinkPHP implementation callback ....