Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NGINX config:
- =============
- map $request_uri $new_uri {
- "~^/r(/[\S]+)\.(png|jpe?g)\?a=(\d+)$" $1.$2?x=$3;
- }
- server {
- listen 80;
- server_name localhost;
- root html;
- location / {
- index index.html index.htm;
- if ($new_uri) {
- rewrite ^ $new_uri permanent;
- }
- }
- }
- cURL log:
- =========
- G:\OpenResty\OpenResty11782\x86>curl -v "http://localhost/r/some/path/image.jpg?a=100"
- * Trying 127.0.0.1...
- * TCP_NODELAY set
- * Connected to localhost (127.0.0.1) port 80 (#0)
- > GET /r/some/path/image.jpg?a=100 HTTP/1.1
- > Host: localhost
- > User-Agent: curl/7.62.0
- > Accept: */*
- >
- < HTTP/1.1 301 Moved Permanently
- < Server: openresty/1.17.8.2
- < Date: Tue, 20 Jul 2021 03:38:01 GMT
- < Content-Type: text/html
- < Content-Length: 175
- < Location: http://localhost/some/path/image.jpg?x=100?a=100
- < Connection: keep-alive
- <
- <html>
- <head><title>301 Moved Permanently</title></head>
- <body>
- <center><h1>301 Moved Permanently</h1></center>
- <hr><center>openresty/1.17.8.2</center>
- </body>
- </html>
- * Connection #0 to host localhost left intact
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement