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.

I've cleaned up my nginx config replacing all the ifs with try_files but I've got this last one that is bugging me. I wan't it to behave like try_files only if the HTTP method is not DELETE. Delete is used to remove the cached file.

Thanks for your lights!

location / {
    if ($request_method ~ ^DELETE$) {
        rewrite ^/(.+)$ /index.php?url=$1 last;
    }
    if (-e $request_filename) {
         break;
    }
    if (!-e $request_filename) {
         rewrite ^/(.+)$ /index.php?url=$1 last;
    }
}

BTW : the more I think about this, the more it seems to be quite insecure…

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The solution I've found is to keep the first if but replace the two others with the better try_files.

location / {
    if ($request_method ~ ^DELETE$) {
        rewrite ^ /index.php last;
    }

    try_files $uri $uri/ /index.php?$args;
}
share|improve this answer

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.