0

I am trying to convert this Nginx rule:

if ($args ~* ^file=(.*)$)
        {
            set $filename $1;
            add_header Content-Disposition "attachment; filename=$filename";
    }

so it can work on Apache 2.2 , but the only online tool for converting that I found uses "if" directive which Apache 2.2 does not understand.

Can someone help please?

Regards.

1
  • Let me give you a comparison: you're trying to convert an Objective-C snippet into a shell-script. Good luck! A better question would be, why are you trying to convert from nginx to Apache 2? A cold winter, and you're trying to use Apache to warm up the room? :-)
    – cnst
    Commented Mar 20, 2013 at 17:35

1 Answer 1

0

This form of question seems to come up a good bit : "please convert this snippet of my conf from Apache to NGinx" (or vice versa). Apache and NGinx operate quite differently so it doesn't make sense to just translate one conf directly to another. Each have their own best practice and the only way to end up with a sane, manageable conf file is to step back and look at the end result you're trying to achieve.

It looks like you're trying to force the clients' browser to download (as opposed to view) a given URL when the file=x paramater is set. In Apache, the usual way to achieve this is using the FilesMatch and Header directives. Here's an example of how to do that. Now, that example is matching against the path rather than the parameters. Without more context, it's hard to tell whether you really need to be doing this with parameters. You would need to provide at least the location block that's relevant the above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .