logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache renaming download files to .xml
Author
Simon T



Joined: 09 Aug 2018
Posts: 1
Location: New Zealand, Wellington

PostPosted: Mon 13 Aug '18 11:03    Post subject: Apache renaming download files to .xml Reply with quote

Hi,

I am managing a web site for a geocaching event. I have a little experience – but I am more a beginner than an expert, so apologies in advance if I’m things wrong.

The site is running on an UBUNTU LAMP setup, 16.04.4 LTS (xenial) and running Apache 2.4.18 (Ubuntu).

I have a download page where I am wanting to provide files of geo-expeditions for users to download and then copy to their GPS receivers - the GPS expects them to be named .gpx.

The files that contain the actual data for have the extension .gpx but are actually xml – you can open them and see the XML tags.

The problem I am having is forcing the browser to download the file without, and I don’t know whether it’s Apache or the browser, renaming them to .xml

I have tried setting .htaccess directives such as:

AddType application/xml .gpx
<FilesMatch "\.(gpx)$">
ForceType application/octet-stream
Header add Content-Disposition "attachment"
</FilesMatch>

and a whole bunch of other MIME permutations of octet-stream/xml/text etc but nothing has worked. There's lots on the Internet, but not much when the target file is xml - and where I have found suggestions, most end up with the download hanging and getting a (partial) file at the destination.

The tag for triggering the download includes the download directive – e.g.

<a href="./downloads/GeoEx - Dry Creek (GPX).gpx" download>GeoEx - Dry Creek (GPX).gpx</a>

but regardless the download gets renamed as .xml at the client browser on download.

Can anyone suggest what I need to do make this work?

Many thanks for taking the time to read, and in advance for any responses.

Best, Simon.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Tue 14 Aug '18 16:49    Post subject: Reply with quote

Hi Simon,
I wonder why you add application/xml and alter try to force application/octet-stream.

However is AllowOverride set to All that the .htaccess works?
Back to top


Reply to topic   Topic: Apache renaming download files to .xml View previous topic :: View next topic
Post new topic   Forum Index -> Apache