New in CWP Edge-LatestFree with every CWPpro licenceWebsites up to 300x faster

CWP now includes LSPHP, LSAPI-Cache and CWP Cage at no extra cost with all CWPpro licences. The LSAPI-Cache plugin is integrated into our WordPress and other script installers, and CWP Cage gives every user complete isolation. Available now in the CWP Edge-Latest version.

Get CWPpro ›

Stop Apache from opening file

Started by Starburst, December 18, 2024, 04:03:07 PM

Previous topic - Next topic

Starburst

Anyone know how to stop Apache from opening a text file that has no extension.

e.g. TIME, PublicKey, etc. - Basically anything without an extension.

Ref. https://mariadb.gb.ssimn.org/

Need those files to download, instead of open.

leisegang

IF you make a simple HTML page with the following code it will be downloaded as a file:

<a href="somepathto.pdf" download="filename">

If you have Apache add this to the .htaccess file:

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

Starburst

Thanks for the suggestions, got it working with a .htaccess

Where I was trying was under <Directory> I was trying to figure out how to put it there.
Currently:

QuoteAddType application/octet-stream .iso
AddType application/octet-stream .rpm

Tried adding:
QuoteForceType application/octet-stream TIME
But didn't work.

overseer

I think you're on the right track, but maybe set it more broadly?
DefaultType application/octet-stream

Or did you try the Content-Disposition header?
<filesMatch "^([^.]+)$">
Header set Content-Disposition "attachment"
</filesMatch>