我有几套url,我需要通过sub_filter更改url
http://www.example.com/dir1/dir2/config.php?id=100
我想更改url以获得像这样的直接文件名
http://www.example.com/dir1/dir2/100.mp4
我试过了 :
sub_filter config.php?id=([0-9]+) ([0-9]+).mp4;
但没有任何变化。
这是如何正确的sub_filter和正则expression式
谢谢
从你的书面的尝试,不清楚你是否正确地把它放在你的conf文件。 在这里看到文档:
http://nginx.org/en/docs/http/ngx_http_sub_module.html
它需要string,但是你没有划勾你的string。 我不相信sub_filter可以采取正则expression式。 有一个叫做substitutions_filter的第三方模块:
https://stackoverflow.com/questions/12463640/nginx-sub-filter-rewrites
此外,请注意,该sub_filter只是改变HTML输出。 我觉得你正在寻找URL重写,而不是改变输出的HTML,而是改变请求的URL。
另见: https : //www.nginx.com/blog/creating-nginx-rewrite-rules/