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
Solved

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

Posted on 2013-01-25
9
597 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 80

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
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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