Solved

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

Posted on 2013-01-25
9
602 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 82

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

617 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