Hi Igor,
maybe my issue was not fully clear but your suggestion puts me on the
right way .... thanks a lot !!
What I'm using now (and it seems working) is:
RewriteEngine on
RewriteCond %{QUERY_STRING}
^(.*)[\&|\?]*filename=([\w|\d|\.|\%| ]*)[\&]*(.*)$
RewriteRule .* - [E=FILENAME:%2]
Header set "Content-disposition" "attachment;
filename=%{FILENAME}e" env=FILENAME
UnsetEnv FILENAME
The main difference is that myfile.txt was just an example, ie, I
should be able to handle any value and that parameter in any position.
For instance:
/download/files/1ytreefecsw?filename=first.txt
/download/files/1ytreefecsw?param1=value1&filename=second.txt¶m3=value3
Ste
On 17/02/2010 0.36, Igor Cicimov wrote:
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@xxxxxxxxx>
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@xxxxxxxxx>
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@xxxxxxxxxxxxxxxx
" from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
--
Stefano Nichele
Funambol Chief Architect
Funambol :: Open Source Mobile Cloud Sync and Push Email
|