i have few sets of urls and i need to change the url via sub_filter
http://www.example.com/dir1/dir2/config.php?id=100
and i want to change the url to get the direct filename like this
http://www.example.com/dir1/dir2/100.mp4
i tried :
sub_filter config.php?id=([0-9]+) ([0-9]+).mp4;
But nothing changes.
how is the correct sub_filter and regular expression for this
thanks
Best Answer
From your written attempt, it's not clear whether you correctly placed it in your conf files. See documentation here:
http://nginx.org/en/docs/http/ngx_http_sub_module.html
It requires strings, but you have no ticks delimiting your strings. I don't believe that sub_filter can take regex. There is a 3rd party module called substitutions_filter for that:
https://stackoverflow.com/questions/12463640/nginx-sub-filter-rewrites
Also, do note that that sub_filter merely changes the HTML output. I get the feeling you are looking for URL rewrites instead, changing the requested URLs instead of changing the output HTML.
Also see: https://www.nginx.com/blog/creating-nginx-rewrite-rules/