Solved

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

Posted on 2013-01-25
9
601 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
9 Comments
 
LVL 81

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 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