0

Let's say a user tries to access a given image on my website using the following URL: http://www.mywebsite.com/random/image1.jpg?someParam=100

I need a rewrite rule to this, removing the 'random' node from the path:

http://www.mywebsite.com/image1.jpg?someParam=100

I have found similar question here But in my case, the 'random' changes and I don't know how many such folders are there. How do I do it. ?

1 Answers1

0

You probably don't want this exactly, but here is a starting point:

server {

    ...

    rewrite ^/[a-z]+/(.*)$ $1 last;

}

That will replace anything in a "directory" that is made up of letters, e.g. random/image.php -> image.php, img/test.png -> test.png

tanerkay
  • 261