httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Cicimov <icici...@gmail.com>
Subject Re: [users@httpd] handling parameter in query_string with mod_rewrite
Date Tue, 16 Feb 2010 23:36:05 GMT
Sorry this should have been like this actually

RewriteEngine On
RewriteCond %{QUERY_STRING} ^filename=(myfile.txt)$
RewriteRule   .*  - [E=FILENAME:%1]

to set the FILENAME variable to myfile.txt value.

Igor

On Wed, Feb 17, 2010 at 10:30 AM, Igor Cicimov <icicimov@gmail.com> wrote:

> 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.nichele@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-unsubscribe@httpd.apache.org
>>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>

Mime
View raw message