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 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.

share|improve this question
    
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 Mar 20 '13 at 17:35
add comment

1 Answer

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.

share|improve this answer
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.