RewriteRule doesn't work with the query part or the URI thus will not work
in your case. You need to try RewriteCond directive combined with
RewriteRule. Something like this maybe?

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(filename=myfile.txt)$
RewriteRule   .*  - [E=FILENAME:%1]
Header set "Content-disposition" "attachment; filename=%{FILENAME}e"
env=FILENAME

I'm not sure though about the effect of the Header set directive, is it
going to have a global effect afterwords or not?

Igor

On Wed, Feb 17, 2010 at 9:21 AM, Stefano Nichele
<stefano.nich...@gmail.com>wrote:

> Hi All,
> I would need some help with mod_rewrite :-( .
> What I would need is to add an header to the response if the request
> contains a URL parameter and the value of that parameter should be used in
> that header.
>
> Just  to clarify, if the url is:
>
> /download/files/1ytreefecsw?filename=myfile.txt
>
> I would like to return this file /download/files/1ytreefecsw setting in the
> response "Content-disposition" header with value myfile.txt:
>
> "Content-disposition: attachment; filename=myfile.txt
>
> I was able to do this thing checking a request header using:
>    SetEnvIf x-filename "^(.+)$" FILENAME=$1
>    Header set "Content-disposition" "attachment; filename=%{FILENAME}e"
> env=FILENAME
>
> but now i need to do similar thing using a parameter.
>
> I understand that there is not a simple way to access to the query_string
> and actually this is not possible using SetEnvIf and it seems the right way
>  is using mod_rewrite .... but i don't find the solution.
> At the moment i'm trying something like:
>
>    RewriteEngine on
>    RewriteRule   ^(.*)filename=(.*)$  $1 [E=FILENAME:$2]
>    Header set "Content-disposition" "attachment; filename=%{FILENAME}e"
> env=FILENAME
>
> but it doesn't work  :-((
>
> Could you help me ?
>
> Thanks
> ste
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
>  "   from the digest: users-digest-unsubscr...@httpd.apache.org
> For additional commands, e-mail: users-h...@httpd.apache.org
>
>

Reply via email to