Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Lets say i get a GET request to file /dir/01/23/file.ext. I would like to serve the file /dir/01/23 which is an extensionless file. The filename should be file.ext rather then 03 and the mime of .ext should be used. How do i write a rule in nginx to do that?

share|improve this question
add comment

1 Answer

rewrite  ^/dir/01/23/file.ext$  /dir/01/23  break;

or

rewrite  ^(.*)/file.ext$  $1  break;

you may also need to specify dedicated location. For example:

location /dir {
  root   $docroot;
}
share|improve this answer
    
I believe that will work but i wont be able to try until tomorrow. Nice answer –  acidzombie24 Nov 21 '11 at 15:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.