Solved

how to make with apache + autoindex for *.txt files are downloaded and not opened

Posted on 2013-01-25
9
589 Views
Last Modified: 2013-02-02
I have actived autoindex with commande +Indexes for one folder.
I want all file listed can be downloaded and not opened.

when files listed are *.txt when I click on the file is opened.
me whant when I click on *.txt this file are downloaded.
0
Comment
Question by:thierry91
  • 6
  • 2
9 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 38820857
in the htaccess for that directory
/foo/.htaccess:
RemoveType .txt
0
 
LVL 1

Author Comment

by:thierry91
ID: 38821159
no, this not work
after have added this in .htaccess is same. and same if I add this in httpd.conf.
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 500 total points
ID: 38821633
in your configuration (httpd.conf or .htaccess)

AddType application/download-me      .txt
0
 
LVL 1

Author Comment

by:thierry91
ID: 38821769
same this not work.
this is my mine part in my conf apache 2.4.3 :

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php .php3 .html .htm
    AddType text/html .gx .pube
    AddEncoding x-gzip .gz
    AddType application/x-javascript .js
    AddType text/css .css
    AddType text/xml .xml
    #AddHandler cgi-script .cgi
    #AddHandler type-map var
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
    AddType audio/mpeg     .mp3 .MP3
    AddType audio/playlist .m3u .M3U
    AddType audio/x-scpls  .pls .PLS
    AddType audio/ogg .oga .ogg .spx .OGA .OGG .SPX
    AddType video/ogg .ogv .OGV
    AddType application/ogg .ogx .OGX
    AddType audio/flac .flac .FLAC
    AddType audio/annodex .axa .AXA
    AddType video/annodex .axv .AXV
    AddType application/annodex .anx .ANX
    Addtype application/xspf+xml .xspf .XSPF
    AddType texte/x-composant .htc .HTC
    AddType application/download-me .txt
    <files *.js.gz>
      AddType "text/javascript" .gz
      AddEncoding gzip .gz
    </files>

    <files *.css.gz>
      AddType "text/css" .gz
      AddEncoding gzip .gz
    </files>

    <files *.xml.gz>
      AddType "text/xml" .gz
      AddEncoding gzip .gz
    </files>
</IfModule>

Open in new window

0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 38821898
can you please check what contentype header is send to your browser (use a FF add-on like firebug, LiveHTTPheader, etc.)
0
 
LVL 1

Author Comment

by:thierry91
ID: 38826073
with firefox file txt is downloaded but not with IE, Chrome, Opera.



http://*********/too.txt

GET /too.txt HTTP/1.1
Host: ************
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://********/
Cookie: __utma=259398038.5993309.1306913933.1317908675.1326825895.27

HTTP/1.1 200 OK
Date: Mon, 28 Jan 2013 10:00:34 GMT
Server: Apache
Last-Modified: Sat, 26 Jan 2013 01:47:44 GMT
Etag: "c-4d4273aee0b89"
Accept-Ranges: bytes
Content-Length: 12
Keep-Alive: timeout=15, max=40
Connection: Keep-Alive
Content-Type: application/download-me
----------------------------------------------------------

Open in new window

http://*********/too.txt

GET /too.txt HTTP/1.1
Host: ************
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://********/
Cookie: __utma=259398038.5993309.1306913933.1317908675.1326825895.27

HTTP/1.1 200 OK
Date: Mon, 28 Jan 2013 10:00:34 GMT
Server: Apache
Last-Modified: Sat, 26 Jan 2013 01:47:44 GMT
Etag: "c-4d4273aee0b89"
Accept-Ranges: bytes
Content-Length: 12
Keep-Alive: timeout=15, max=40
Connection: Keep-Alive
Content-Type: application/download-me
----------------------------------------------------------

Open in new window

0
 
LVL 1

Author Comment

by:thierry91
ID: 38826250
I have solved partialy the problem. now with this in .htaccess :

<FilesMatch "\.(?i:txt)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>

Opera and IE display prompt for download file, BUT chrome NO.
0
 
LVL 1

Accepted Solution

by:
thierry91 earned 0 total points
ID: 38826348
the solution is in .htaccess add :

<FilesMatch "\.(?i:txt)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>

with this, Chrome, IE, Opera, Firefox propose the download.

Thx all for your help
0
 
LVL 1

Author Closing Comment

by:thierry91
ID: 38846347
My solution work for and with all browser
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now